[ZODB-Dev] Error message with simple ZODB usage

kw kw_odonian at yahoo.com
Tue Oct 26 14:47:58 EDT 2004


Oops, my original message was mangled, sorry.  Here's
the code again.  I'm using ZODB 3.3c1, python 2.3.4 on
OpenBSD.


I'm new to the ZODB and am writing some simple code to
learn how to use it; when I try to add and then commit
my persistent container, I get the message:

No handlers could be found for logger ZODB.FileStorage

The testing code is below - and if there are mistakes
or breaches of ZODB style, corrections are more than
welcome.  The "No handlers..." message appears when I
use the "addBob" argument for the first time, but not
subsequently.



#!/usr/bin/python

"""
Testing ZODB and persistence with a simple example.
"""

import sys
sys.path.append('/web/ZopeX3c1/lib/python/')

import ZODB, ZODB.FileStorage
import persistent

class Person(persistent.Persistent):

    def __init__(self):
        self._type = "Human"



class Man(Person):

    def __init__(self, name):
        Person.__init__(self)
        self._name = name
        self._reason_for_being = "eat, sleep, work."

    def __repr__(self):
        out = "My name is " + str(self._name) + " and
my raison d'etre is " + str(self._reason_for_being)
        return out



class PeopleDirectory(persistent.Persistent):

    def __init__(self):
        self._directory = []

    def addPerson(self, person):
        self._directory.append(person)
        self._p_changed = 1

    def __repr__(self):
        out = ""
        for person in self._directory:
            out += str(person)
        return out

if __name__ == "__main__":

    import transaction

    if "init" in sys.argv[1:2]:
        db =
ZODB.DB(ZODB.FileStorage.FileStorage('test_people.fs',
create=1))
        root = db.open().root()
        root['people'] = PeopleDirectory()
        transaction.commit()

    if "addBob" in sys.argv[1:2]:
        db =
ZODB.DB(ZODB.FileStorage.FileStorage('test_people.fs'))
        people_dir = db.open().root()['people']
        Bob = Man("Bob")
        people_dir.addPerson(Bob)
        transaction.commit()

    if "show" in sys.argv[1:2]:
        db =
ZODB.DB(ZODB.FileStorage.FileStorage('test_people.fs'))
        people_dir = db.open().root()['people']
        print people_dir



		
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 


More information about the ZODB-Dev mailing list