[ZODB-Dev] connection.sync() kills _p_changed?

Greg Ward gward@mems-exchange.org
Fri, 13 Jul 2001 11:48:16 -0400


On 13 July 2001, Christian Robottom Reis said:
> If a persistent object has been modified, it's _p_changed is set to 1.
> However, if I call connection.sync() at this point, the object's data is
> preserved _but_ it's _p_changed is lost (it becomes None, AFAICS).

That's not the behaviour I'm observing -- I just tried this, and any
local, uncommitted modifications are lost on calling sync().  This seems
correct: I'm sync'ing back to the on-disk database, and my local changes
aren't on disk.  In fact, the implementation of Connection.sync() is
pretty clear:

    def sync(self):
        get_transaction().abort()
        sync=getattr(self._storage, 'sync', 0)
        if sync != 0: sync()
        self._cache.invalidate(self._invalidated)
        self._incrgc() # This is a good time to do some GC

So sync() is just get_transaction().abort() plus cache invalidation.
And some other stuff that I don't really understand.  ;-)

> Is this the expected behaviour? For now I'm saving _p_changed for the
> changed object and restoring it after sync(), but I'm not sure that's
> entirely sane.

Sounds pretty insane to me.

        Greg
-- 
Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange                            http://www.mems-exchange.org