[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/src/zope/app/fssync - syncer.py:1.5

Jim Fulton jim@zope.com
Thu, 08 May 2003 10:37:26 -0400


Jeremy Hylton wrote:
> On Tue, 6 May 2003 18:04:06 -0400
>  Guido van Rossum <guido@python.org> wrote:
> 
>>There was a problem with _p_serial being wiped out.  As a
>>temporary
>>hack, save+restore it.  XXX But really,
>>Persistent.__setstate__ should
>>preserve _p_serial.
> 
> 
> A question I'm not sure how to answer it whether
> __setstate__() should clear the previous state of the
> object. 

Yes.

 > I can make a special-case for _p_serial if it
> should.

I'm not comfortable with storing _p_serial in the __dict__.
I'm not convinced of the savings and I think it complicates
lots of applications.

At a deeper level, it mixes up meta-state (_p_serial) and
state (__dict__).


> I implemented the current behavior because it seemed most
> natural to think of a __setstate__ operation as setting new
> state on an object.  If the state no longer has a spam
> attribute, then the old spam attribute shouldn't hang
> around.

Right.

> On the other hand, we can think of a __setstate__ operation
> that is only invoked at special times in an object's
> lifetime.  Certainly, zodb only calls __setstate__ on a
> ghost, where there is no state.
> 
> Anyone have other opinions?  I'm leaning towards the 2nd
> option.

My strong opinion is that we shouldn't store meta-state in the dict.

Jim

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