[ZODB-Dev] How to resync with current db

Tim Peters tim at zope.com
Mon Feb 7 15:28:15 EST 2005


[Dieter Maurer]
>> You get hit by the loose coupling of connections to transactions in ZODB
>> 3.2:
>>
>> Tim changed this for ZODB 3.3.

[Paolo Losi]
> I forgot to mention but I was using ZODB 3.3.1alfa... I get the same
> behaviour with it.

If you want to pursue this, please make the effort to post some minimal,
self-contained, executable code.  Details can matter a lot, and having to
guess at what you did (exactly) is too time-consuming.

> ...
> I think I found the proper interface: Connection.sync(). It calls
> _flush_invalidations, as you suggested, and "clean" (abort) the current
> transaction...

Yes, and it's actually the same method as you discovered earlier, which you
spelled obj._p_jar.sync() then.  obj._p_jar is (not always, but in your
examples so far) the Connection object from which obj was loaded.  I suppose
the leading underscore in "_p_jar" makes it a dubious thing to access
directly, but lots of code does so.  In any case, it's clearer to call
sync() directly on a Connection object than indirectly through some other
object's _p_jar attribute.  Back to an earlier question:

      > does it resync all objects or only the instance on which
      > it is invoked?

sync() (however you spell it) applies to all objects loaded from the
(single) Connection.  That's not necessarily "all objects" (for example, you
may have more than one Connection) nor "only the instance" (for example, you
may have loaded multiple objects from a given Connection).



More information about the ZODB-Dev mailing list