Personal tools
You are here: Home Zope & Plone tips Describing the current transaction in Zope 3 for undo purposes
Navigation
 
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Describing the current transaction in Zope 3 for undo purposes

by tibi last modified 2007-05-08 18:39

In order to implement Gmail-style Undo labels integrated into the UI, you'll have to store more information about the operation. This can be done by getting the current ZODB transaction and adding a note to it. This information is later available in the description attribute of the transaction entry in the transaction history log.

To add a transaction description

import transaction
transaction.get().note('label-something-done')

To get the translated transaction description from the transaction history log

def getLastTransactionNote(context=None):
    umgr = zope.component.getUtility(IUndo, context=context)
    transactions = umgr.getTransactions(context=context)
    last_transaction = transactions[0]
    return _(last_transaction['description'])

Of course, you'll probably want to get the transaction id as well, to be able to do an undo. To get more info about this read the zope.app.undo.interfaces.IUndo interface description.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: