[ZODB-Dev] Using Ape to map zclass property sheets

Shane Hathaway shane at zope.com
Tue May 13 15:02:33 EDT 2003


Rocky Burt wrote:
> I have an interesting situation.  Take the following code:
>   # obj is an instance of a ZClass
>   hasattr(obj, 'propertysheets')  # returns 1
>   obj.__dict__.has_key('propertysheets')  # returns 0

This means that the class has an attribute that the instance does not 
override.  That's normal.  A instance __dict__ contains only the 
attributes that have been set on the instance.

> It seems to me that this *shouldn't* happen.  What's more, I've noticed
> in Ape's remainder code merely iterates over __dict__ to determine what
> to store.  If I am correct in my conclusions, this means that an
> object's property sheet state (as defined by it's zclass) is being
> lost/forgotton.

Unset properties have a default value from the class.  I imagine that's 
what you're seeing.

> Of course we can put in a special check for propertysheets, but
> shouldn't there be a more standard way to get back all of the attributes
> that exist (which is what i thought __dict__ was supposed to be).

Your code needs to read the propertysheets attribute in order to find 
out all property names.  I can't think of another way to do it.

Shane




More information about the ZODB-Dev mailing list