Describing the current transaction in Zope 3 for undo purposes
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.