[ZODB-Dev] Copying persistent objects between databases
Dieter Maurer
dieter at handshake.de
Tue Nov 23 14:54:02 EST 2004
Thomas Guettler wrote at 2004-11-23 10:02 +0100:
>I need to copy some objects from one database to an other.
>Both are accessed with ZEO.
>It will use one thread. Are there any pitfalls?
You can use the "OFS.CopySupport.CopySource._getCopy" method.
A copy obtained in this way (with the correct destination)
can then be installed with "_setObject()".
>I would like to abort the (readonly) transaction which reads the data
>from the source and commit the transaction which writes the
>data to the destination.
>
>Which transaction does get_transaction() return?
Unless you use "local transaction", "get_transaction()" will
return the single transaction used by both connections.
If you are sure, that you read only (in one connection),
you do not need to worry about commit/abort.
For a connection that was only read, a "commit" is equivalent
to an "abort".
Note that depending on the ZODB version, "commit/abort" may
not lead to cache maintenance (flushing unused objects from the cache).
Memory consumption by the read only connection may grow unboundedly.
You can consider using "connection.sync()" to force cache maintenance
(it implies a transaction abort; be careful).
--
Dieter
More information about the ZODB-Dev
mailing list