[Zope-dev] Undo product stops working with recent Zope (StorageTransactionError)
Hi, I have a product that patches Zope so that the Undo screen also accepts a date and time for when to roll back to (on pypi as Products.Undoer). It used to work, but with the most recent versions of Zope this error appears if the Undo by date is used more than once: 2012-01-24 13:45:32 ERROR Zope.SiteErrorLog 1327409132.230.397033237621 http://localhost:8080/Plone/undo_changes_by_date Traceback (innermost last): Module ZPublisher.Publish, line 134, in publish Module Zope2.App.startup, line 301, in commit Module transaction._manager, line 89, in commit Module transaction._transaction, line 329, in commit Module transaction._transaction, line 441, in _commitResources Module ZODB.DB, line 990, in tpc_begin Module ZEO.ClientStorage, line 1116, in tpc_begin StorageTransactionError: Duplicate tpc_begin calls for same transaction The code looks like this: def undo_changes_by_date(self, date=None, REQUEST=None): Undoes changes made to the database after a given date; if a date is not specified, all changes are undone. if date is None: date = float(0) elif type(date) == types.StringType: date = float(DateTime(date)) else: date = float(date) transactions = self._p_jar.db().undoLog(0, 2**32) undo=self._p_jar.db().undo count = 0 for transaction in transactions: if transaction['time'] = date: undo(transaction['id']) count += 1 if REQUEST: return MessageDialog( title='Result of undoing transactions', message=em%s/em transactions were undone % count, action='./manage_UndoForm' ) return count Any ideas? Do I need to do a tpc_begin myself? -Morten ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Undo product stops working with recent Zope (StorageTransactionError)
On Tue, Jan 24, 2012 at 2:14 PM, li...@nidelven-it.no wrote: It used to work, but with the most recent versions of Zope this error appears if the Undo by date is used more than once: The undo API has changed with ZODB 3.10. As noted in the changelog: The API for undoing multiple transactions has changed. To undo multiple transactions in a single transaction, pass a list of transaction identifiers to a database's undoMultiple method. Calling a database's undo method multiple times in the same transaction now raises an exception. Your code calls undo multiple times, and needs to be changed accordingly. Hanno ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Undo product stops working with recent Zope (StorageTransactionError)
On Tue, 24 Jan 2012 14:50:44 +0100, Hanno Schlichting ha...@hannosch.eu wrote: On Tue, Jan 24, 2012 at 2:14 PM, li...@nidelven-it.no wrote: It used to work, but with the most recent versions of Zope this error appears if the Undo by date is used more than once: The undo API has changed with ZODB 3.10. As noted in the changelog: The API for undoing multiple transactions has changed. To undo multiple transactions in a single transaction, pass a list of transaction identifiers to a database's undoMultiple method. Calling a database's undo method multiple times in the same transaction now raises an exception. Your code calls undo multiple times, and needs to be changed accordingly. Aha. OK, thanks! :) Regards, Morten ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )