This is a good question that I'm not sure of the completely technically
correct answer to.  But here's my best shot.  Part of what composes a
"Zope object" is that the object inherits characteristics from the
"Persistence.Persistent" class.  This base class overrides Python's
normal __setattr__ and __getattr__ instance methods.  When a persistent
object is queried for a subobject (e.g. its __getattr__ is called), it
does some magic to pull that subobject out of persistent storage.
Likewise, when you attach an attribute to an object (e.g. its
__setattr__ is called), this base class does its thing and when a
transaction is committed, the object is written out to the ZODB.
Because mutable objects have methods that do an end-run around
__setattr__ (such as list.append, dict.__setitem__, etc.), Zope won't
know that the object has changed because setattr never gets called.
However, when you do the persistence shuffle (ala;
m['foo']=bar;, __setattr__ does get called on the parent
object, and Zope therefore knows the object has been changed.

Others may elaborate or correct, I'm certain. 

> -----Original Message-----
> From: Pete Kazmier [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 24, 2000 8:32 PM
> Subject: Re: [Zope] Subclassing from Custom Python Classes
> Thank you for the useful information!!
> I do have one more question regarding your persistence comments.  How
> does using a temporary name notify the Zope persistence machinery that
> has changed?  Doesn't '' do nothing in Python if
> one already did a ''?  In the end, aren't they referencing
> the exact same object?  Hows does Zope know its different?
> Thanks again,
> Pete

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to