[Zope-dev] Question about _v_ attributes and database connections

Marco Bizzarri emmebi at icube.it
Tue Mar 9 07:05:20 EST 2004


On Mon, Mar 08, 2004 at 09:34:28AM -0500, Jeremy Hylton wrote:
> 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.

 What I would like to do is to have an hook to the removal of a _v_
 attribute, so that I can perform some action *BEFORE* losing any
 reference to the object itself. I look at the setattr code in
 cPersistence.c and tried also to write my own __setattr__, but I do not
 know what should be called *AFTER* my code. What I would do is:


 def __setattr__(self, key, value):
     if key[0:3] == '_v_': doMyStuff()
     doStandardStuff()

 but I do not know what doStandardStuff actually is.


 Regards
 Marco
 
> Jeremy
> 

-- 
Marco Bizzarri - Amministratore Delegato - Icube S.r.l.
Sede:   Via Ridolfi 15 - 56124 Pisa (PI), Italia 
E-mail: m.bizzarri at icube.it		WWW: www.icube.it	
Tel: 	(+39) 050 97 02 07		Fax: (+39) 050 31 36 588	



More information about the Zope-Dev mailing list