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.




About Michael Howitz

I am a software developer at gocept in Halle (Saale). In development I mainly use Python, Zope, ZTK and Pyramid.
This entry was posted in Python, Zope and tagged , , , . Bookmark the permalink.

One Response to Zope – undo transactions via debug console

  1. Pingback: Zope – undo transactions via debug console – gocept blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s