Compatibility with ZODB

Gary H
  • Gary H

    Gary H - 2004-10-13

    First, thanks for Boa.

    Second, 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 =
    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):
   = 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.

    Any direction appreciated.

    • Gary H

      Gary H - 2004-10-14

      Jimminy, I've answered my own question: I'd used OOBTree to create and populate the database in a stand-alone python module outside of boa:

      db = ZODB.config.databaseFromURL('calendar.conf')
      conn =
      dbroot = conn.root()
      from BTrees.OOBTree import OOBTree
      dbname = 'calendar_db'
      dbroot[dbname] = OOBTree()
      sched = dbroot[dbname] # DB reference variable

      The solution was to delete the old db, then create and populate the database from within the boa 'wxFrame' module. After doing so, I moved the code (posted earlier) to another module, added some data-returning functions, then imported it into the 'wxFrame' module, with a, 'from Blah import *' statement. Now, when the functions are called from within wxFrame, guess what? It works...

      Not a Boa quirk I'll wager, but a poor understanding of ZODB and persistence on my part. The more I learn the dumber I seem to get... :)


Log in to post a comment.