On 06/10/2010 15:19, Jim Fulton wrote:
> _v_ attributes should be dropped whenever an object's state is
> cleared.

It would be great if there was some clear documentation covering all 
this in the ZODB package...

> So, you want to update an object using old state.
> I would use:
>    base._p_invalidate() # remove state, including volatiles, no matter what
>    base._p_activate()       # make sure we're not a ghost
>    base.__setstate__(state) # change the state
>    base._p_changed = True   # marke object as dirty
> This isn't foolproof, depending on how an object uses _v_.  For
> example if __setstate__ sets _v_s if they aren't already set, then the
> above code would likely fail, as the _v_s would reflect the old state,
> not the new.

Okay, it works for the Zope 2.12 problem at hand:

> If this use case is important, it would be better for ZODB tp provide
> an API to handle this directly, so you didn't have to hack together
> existing APIs.

Well, I have customers who think it's important, but it depends on 
whether you still think Zope 2 with TTW editing is important ;-)

> I assume this code will ultimately be followed by a commit.


> Well, for your use case, you're going to be committing a change to the
> object.  That will cause instances of the object in all other
> connections to be invalidated, dropping their volatile attributes.

Cool :-) I'll take this on trust, I don't want to contemplate trying to 
write a test that proves it ;-)


Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk
For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to