[Zope] Persistence-safe __dict__?

Terry Hancock hancock at anansispaceworks.com
Tue Jan 6 12:14:34 EST 2004


Every once in awhile, it's handy in Python to just access 
the __dict__ attribute and get the whole list of defined
names in a class or instance.  It's not always well-advised,
but sometimes it's awfully useful.

I unwittingly used this technique with a Zope persistent
object recently, and got some extremely weird errors due
to __dict__ occasionally evaluating as {}.

My guess is that this is because __dict__ access is not
persistence-safe (perhaps the {} bug occurs when the
object is in it's "phantom" state?).  Anyway, in that case,
I could work around the problem by listing the attributes
I wanted explicitly (actually I used the names defined in
the object's Interface, which is kind of cool from a design
perspective, but that's another issue).

Anyway, is there a safer way to get the same information
as __dict__ from a Persistent object?

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com



More information about the Zope mailing list