Jason Abate wrote:
Michel-
Are you calling Persistent.__setstate__(self, state) in your setstate method? If you don't call it, the persistent machinery would probably be very unhappy, and since it's written in C, might core dump... just an idea.
Where is the Persistent class defined?
It's a C class, defined in lib/python/ZODB/cPersistent.c.
All I can find is lib/python/Persistence.py,
Persistence.py can be thought of as a registry. A database, like BoboPOS or ZODB stuffs it's persist class there when it is imported. This allows application code to be written that doesn't depend on the specific database used.
but that only contains the Zope license information and a doc. string. No actual classes are defined there. When I try to subclass Persistent, I get an error about the class not being found:
import Persistence class myclass(Persistence.Persistent): ... def __init__(self): ... print "In init" ... Traceback (innermost last): File "<stdin>", line 1, in ? AttributeError: Persistent
Am I missing something here?
You need to import ZODB first. import ZODB, Persistence class myclass(Persistence.Persistent): ... The idea is that a "main" module (like Zope) imports ZODB before ant application modules are imported so that Persistence has Persistent when needed.
Do things work differently if the module is written in C?
In this case, the difference arises from the way the Perssitence module is used as a sort of registry. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.