[Grok-dev] Persistence issue with grok.Model

Martijn Faassen faassen at startifact.com
Fri Jan 2 16:05:14 EST 2009


Brandon Craig Rhodes wrote:
> Martijn Faassen <faassen at startifact.com> writes:
> 
>> I wonder why the ZODB is not able to perceive a __dict__ access as an
>> attribute access, however.
> 
> The definition of Python itself specifies that ``myobject.__dict__``
> does a *direct* return of the object dictionary, without invoking *any*
> of the attribute-getting machinery of the class or metaclass.  This is
> necessary so that classes and metaclass methods themselves can somehow
> bypass themselves and get to the "real" instance variables!
> 
> So the ZODB cannot intercept ``__dict__`` because, well, nobody can. :-)

Yeah, that sounds like a reasonable explanation.

Of course there'd still be the possibility for a hook in Python that 
would allow a very special metaclass to do something as a side-effect of 
__dict__ access, but it's quite possible this hook doesn't exist.

Regards,

Martijn



More information about the Grok-dev mailing list