[Zope-dev] Question about _v_ attributes and database connections
Jeremy Hylton
jeremy at zope.com
Mon Mar 8 09:34:28 EST 2004
On Fri, 2004-03-05 at 16:57, Dieter Maurer wrote:
> >3) is it possible to disable caching of some object?
>
> No, but you can (in most cases) flush it again
> by calling its "_p_deactivate" method.
>
> You can always do it by assigning "None" to "_p_changed", but this
> is highly unsafe. You should not do it (unless you really know
> what you are doing).
Another was of saying this is that the cache performs an important role
in maintaining object identity. It's not possible to use a persistent
object without using a cached version of it. If you think you need to
disable caching, you should probably say something more about what you
are trying to do.
> >4) when an _v_ attribute is removed, what code of the object/attribute
> >itself is called?
>
> The object's "__del__" method (if defined).
> This means the object that was bound to the "_v_" attribute
> not the object that had the "_v_attribute".
The setattr hook in cPersistence.c is called when an attribute is
removed (del obj.attr). An __del__() method would only be called if the
last reference to the object was also deleted. And __del__ is to be
avoided whenever possible.
Jeremy
More information about the Zope-Dev
mailing list