Simon Burton wrote:
On Sun, 28 Jan 2007 19:00:33 +0100
"Dieter Maurer" <[EMAIL PROTECTED]> wrote:

Simon Burton wrote at 2007-1-27 15:18 -0800:
I have a Persistent object, however, its attributes only
get loaded from the storage when I request a specific attribute.
Problem is, I don't know the names of the attributes necessarily. I was trying to just query the __dict__ but
this does not trigger a load. Is there another way to do this ?
Accessing (almost) any attribute (even a non existing one) will load
the object. There are a few exceptions: attributes starting with "_p_"
or "_v_".


Yes. I looked at the dir function, it seems that when it accesses the 
"__members__"
attribute this triggers a load.

This is ZODB-fu. So be it.


Broadly, if you just request an object (rather than a method or attribute), then the ZODB returns a 'ghost' object. The ghost object is transformed into the real object once a method or attribute are used.

If you have a persistent object that you think is a ghost, you can call _p_activate() on it. That will load __dict__ and turn it into the full object for you to use as you want.

At least, that's what I've found - if this is wrong then someone should speak up!

Miles


_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to