[ZODB-Dev] re: re: Newbie questions re persistent objects and connections: [Was: can Leo...]

Edward K. Ream edreamleo at charter.net
Tue Sep 12 11:10:37 EDT 2006


> Another approach would be to have in-memory copies of the objects in  the
> zodb (they could even be the same class, just without a database
> connection).  Saving the file pushes the copy's data to the ZODB and
> commits a transaction.  This would work with a single long running
> connection or with short connections, opened just for save and load.

Many thanks for this reply.  Using copies of zodb objects should be
straightforward. Having only one short-lived connection open at a time would
probably keep things simplest.

> I think the reverting use case needs a mechanism other than ZODB undo.

If at most one connection is ever open, a Leo-revert is just a pull from the
zodb, something like:

# Exception-handling omitted...
connection = db.open()
v = connection.root().get(fileName)
v2 = c.zodbTreeToLeoTree(v)
get_transaction().commit()
connection.close()
c.setRootVnode(v2)
c.redraw()

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edreamleo at charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------




More information about the ZODB-Dev mailing list