ZODB and Boa

Diez B. Roggisch deetsNOSPAM at web.de
Wed Oct 13 14:39:52 EDT 2004


Gary wrote:

> I'm having some difficulty getting ZODB to play nice with Boa.
> Specifically, after creating a simple interface with a text field &
> btn, I added a python module and imported it into the main (wxFrame)
> code:
> 
> (python module code)
> import ZODB.config
> db = ZODB.config.databaseFromURL('calendar.conf')
> conn = db.open()
> dbroot = conn.root()
> dbname = 'calendar_db'
> sched = dbroot[dbname]
> 
> from persistent import Persistent
> #from persistent.list import PersistentList
> #from persistent.mapping import PersistentMapping
> 
> class Calendr(Persistent):
>     def __init__(self):
>         self.date = 0
>         self.datedata = ()
>         self.fds = []
>         self.first = []
>         self.second = []
>         self.third = []
>         self.all = []
>         self.stats = {}
> 
> abc = sched[20050101]
> efg = abc.first
> print efg
> (end code)
> 
> When run (from the wxFrame), the textbox value set to 'efg,' an err
> msg states that 'first' is not an attribute of Calendr.
> When the textbox value is set to str(abc), the err msg states:
> <persistent broken __main__.Calendar instance
> '\x00\x00\x00\x00\x00\x00\x00\x1c'>
> 
> When the python module is run directly (thru Boa), it seems to work
> fine, and the print value seen in the code above appears in the Output
> section of the Boa Editor frame.
> 

I encountered similar problems when the objects serialized were imported as
members of a certain module - and then, when that module is not found under
that name when deserializing, the object is broken as yours.  So make sure
that if your object is of type foo.Bar, when deserializing import foo,
containing Bar.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list