mgedmin / zodbbrowser

ZODB browser
http://launchpad.net/zodbbrowser
Other
19 stars 6 forks source link

How to inject types for standalone zodbbrowser? #5

Closed baloan closed 9 years ago

baloan commented 9 years ago

I am using the standalone zodbbrowser 0.11.1 with a ZODB3 database. I can access the database fine but when I insert objects of unknown type into the ZODB the browser only displays:

Attributes
data: {u'account-1': <persistent broken __main__.Account instance '\x00\x00\x00\x00\x00\x00\x00\x01'>,
       u'account-2': <persistent broken __main__.Account instance '\x00\x00\x00\x00\x00\x00\x00\x01'>
}

I'd like to see a formatted printout from repr (or str) instead. The short user guide on pypi at Help! Broken objects everywhere recommends to make sure your application objects are importable from the Python path. But I don't know how.

How do I make the Account class (from the tutorial):

class Account(Persistent):
    def __str__(self):
        ...

known to zodbbrowser in standalone mode so that the persistent broken type are replaced with a str representation of the object instance?

NB: cross posted http://stackoverflow.com/questions/27573993/how-to-inject-types-for-standalone-zodbbrowser

mgedmin commented 9 years ago

I replied on StackOverflow.