Zope – undo transactions via debug console

If you cannot access the root level in Zope 2 via the browser but you are able to use the debug console you have enough to undo transactions.

Start the debug console:

$ bin/zinstance debug

List the transaction descriptions, user names and ids of the last 10 transactions:

>>> from pprint import pprint
>>> pprint(app._p_jar.db().undoInfo(0, 10))

(0 is the youngest transaction, the first one to show)

Undo some transactions:

>>> import transaction
>>> transaction.get().note(u"Undo transactions: ...")
>>> app._p_jar.db().undoMultiple([id1, id2])
>>> transaction.commit()

(id1, id2 have to be the actual id strings from the transaction listing.)

Be aware:

  • Use a sorted list of transaction ids, start with the id of the youngest transaction you want to undo.
  • You cannot undo transactions those objects were changed again later without undoing those transactions, too.
  • The actual undo is executed when calling transaction.commit(). (This might take some time to execute.)
  • You can check the result of your undo using the transaction log as undo only creates an inverse transaction.

 

This blog post first appeared on icemac15.wordpress.com.

Author: Michael Howitz

I am a software developer at gocept in Halle (Saale). To develop software, I mainly use Python, Zope, ZTK and Django.

One thought on “Zope – undo transactions via debug console”

Leave a Reply

%d bloggers like this: