[ZODB-Dev] Undo in run-time

Jeremy Hylton jeremy@zope.com (Jeremy Hylton)
Mon, 28 Oct 2002 17:03:12 -0500


>>>>> "ML" == Magnus Lycka <magnus@thinkware.se> writes:

  ML> What about objects that haven't changed during the undone
  ML> transaction? Are they ok to use even though they've been alive
  ML> while I did undo, closed the connection to ZODB and opened it
  ML> again? Or do I need to get them from the database again?

The transaction has no effect on objects that aren't undone.  So you
can use them without any problem.

  ML> Do I have to close and open ZODB? The Zope Bible p 410 says:
  ML> "Note that you won't notice any changes until you commit the
  ML> transaction and open a new connection to the database."  But
  ML> then they show an example where we see the revival of a deleted
  ML> object without reconnecting...

You do have to do something with the current connection.  Calling it's
sync() method will work.  (See a thread on this subject in the last
few weeks.)

  ML> Also, is there a way to test that an object is out of sync with
  ML> the database or do I need to provoke things with a commit and
  ML> exception handling? (Would that work? Would the offending object
  ML> be located?)

Every time you abort / commit or sync, ZODB will make sure that all
objects are in sync.  If something is out of sync you'll get a
ConflictError at some point.  Note that you can get a
ReadConflictError at any time, not sure during a commit.

  ML> Is there a way for an object to "refresh" itself from the
  ML> database? 

If an object is unmodified, call _p_deactivate().  Then any future
attempt to access will cause a reload of its state from the database.

  ML> Is there any certain way to get rid of the GB'd objects in
  ML> python? Other than to find all references manually and delete
  ML> them one by one? :( (Maybe I should have used weakref
  ML> everywhere...)

I really don't know what will happen with a GB object.  Why don't you
try a simple example and see what happens?

Jeremy