Showstopper: need very basic help with Zope2 persistence
Hi, I'm using Zope2 and am trying to get Persistence working for the first time by creating an object store. I'm using the documentation: http://www.zope.org/Documentation/Reference/ObjectPublishingIntro which has a chunk of code to do a very basic store on a Person. I've tried this code both within and without Zope with no success. I'm wondering whether 1. The code (appended) doesn't work for Zope2? When ExternalMethod->Add'ed into Zope, I get: Zope Error Zope has encountered an error while publishing this resource. exceptions.AttributeError Sorry, a Zope error occurred. When run outside Zope, I get: //D/Zope.W32/Extensions:-) python Person.py Traceback (innermost last): File "Person.py", line 14, in ? object_store = BoboPOS.PickleDictionary("people_store.db") File "D:\Zope-2.0.0a4-src\lib\python\BoboPOS\PickleDictionary.py", line 162, i n __init__ jar=PickleJar.PickleJar(db,cache_size,cache_age=cache_age) File "D:\Zope-2.0.0a4-src\lib\python\BoboPOS\PickleJar.py", line 120, in __ini t__ cache=self.cache=PickleCache(cache_size,cache_age) AttributeError: 'int' object has no attribute 'setklassstate' Is there some new code which works in Zope2 to get persistence? 2. My Zope2 installation is somehow broken? I would really appreciate some help on this (I thought) basic issue as it's a show-stopper for what I'm doing. I didn't expect to have this problem since it seem(ed) so well documented and basic. If this question is somehow unanswerable, I'd like to know that too (so I know to give up)! Thanks, = Joe = P.s., I've tried a bunch of variations and searched code for similar fragments all to no avail. If someone has a code fragment or pointer to working code, please let me know. -=- Code -=- import BoboPOS class Person(BoboPOS.Persistent): "A persistent person" def __init__(self,name,age): self.name=name self.age=age def listDB( self): return "Hello" # define the object store # object_store = BoboPOS.PickleDictionary("people_store.db") # retrieve billy from the object store # if object_store.has_key("billy"): # if billy is in the object store, then # load it from the object store # billy=object_store["billy"] else: # since billy isn't already in the object # store, we must create the object and # place it in the object store. # billy=object_store["billy"]=Person("Billy",77) # normally Zope will handle transactions, # but in this special case, we need to # commit the transaction to save the new # persistent object # get_transaction().commit() # display the object that we retrieved # from the object store # listDB()
participants (1)
-
Joe Grace