[ZODB-Dev] simple example of undo( )

Jeremy Hylton jeremy@alum.mit.edu
Mon, 23 Sep 2002 20:08:52 -0400


  M> First, is this list the right venue for a question like this?  If

This is the right place.

  M> so, am I misunderstanding how undo should work?  This is using
  M> ZODB3-3.1b1 & Python 2.2.1.

You've missed one small point.  undo() on FileStorage is a
transactional operation.  You need to call get_transaction().commit()
after undo().  This will commit the undo.

Unfortunately, this doesn't make your test script work.  There's
another problem, which I'm tempted to call a bug.  You canhack around
the problem.  Add this line after committing the undo() transaction:

conn.sync()

I can't give you a better answer yet.  I'll need to get some help
from some Zope experts.  The problem, in a nutshell, is that the
undo() transaction operates on the database, but not on your current
connection.  When it commits, the database sends an invalidation
message to the connection.  The next time the connection commits a
transaction, it will process the invalidation and update your object.
The sync() method makes this happen explicitly, but I wonder why there
isn't some other implicit mechanism.

Jeremy