[ZODB-Dev] [Enhancement Proposal] Garanteed lifetime for volatile variables

Jim Fulton jim at zope.com
Fri Oct 6 12:10:24 EDT 2006


Dieter Maurer wrote:
> I have put an enhancement proposal at
> 
>   http://www.zope.org/Wikis/ZODB/VolatileAttributeLifetimeGarantee
> 
> It allows applications to declare that they need for 
> some (so called sticky) objects a garanteed lifetime for their
> volatile attributes that extends until at least the next
> transaction boundary.
> 
> 
> This extension makes safe the use of volatile attributes for
> the following cases:
> 
>   * the storage of database connections in "Shared.DC.ZRDB.Connection"
> 
>   * the former use of "_v_skindata" in "Products.CMFCore.Skinnable"
>     (now replaced by a much more complex, less efficient and not
>     completely correct solution)
> 
>   * the use of "_v_is_cp"  in "Archetypes.BaseObject"
>     (and other use of volatile attributes for control purposes).
> 
> This statement implies that the current use is unsafe.
> 
> 
> Feedback is welcome -- either in the Wiki or here.

I'm a little uneasy about baking this policy so deeply into
the infrastructure.  I wonder if the use case can be handled
another way.

A persistent object can override _p_deactivate.  For example:

     def _p_deactivate(self):
         pass

prevents an object from being turned into a ghost unless it is
invalidated.

You could implement your sticky attribute at the application level:


     def _p_deactivate(self):
         if getattr(self, '_p_sticky', False):
            return
         Persistent._p_deactivate(self)

You could provide any policy you want, without making the policy part
of ZODB.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the ZODB-Dev mailing list