Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

Undo product stops working with recent Zope (StorageTransactionError)

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


lists at nidelven-it

Jan 24, 2012, 5:14 AM

Post #1 of 3 (236 views)
Permalink
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 [at] zope
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 )


hanno at hannosch

Jan 24, 2012, 5:50 AM

Post #2 of 3 (228 views)
Permalink
Re: Undo product stops working with recent Zope (StorageTransactionError) [In reply to]

On Tue, Jan 24, 2012 at 2:14 PM, <lists [at] nidelven-it> 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 [at] zope
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 )


lists at nidelven-it

Jan 24, 2012, 11:26 PM

Post #3 of 3 (221 views)
Permalink
Re: Undo product stops working with recent Zope (StorageTransactionError) [In reply to]

On Tue, 24 Jan 2012 14:50:44 +0100, Hanno Schlichting
<hanno [at] hannosch> wrote:
> On Tue, Jan 24, 2012 at 2:14 PM, <lists [at] nidelven-it> 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 [at] zope
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 )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.