Am 11.05.2010, 17:08 Uhr, schrieb Nitro <ni...@dr-code.org>: > Am 11.05.2010, 16:01 Uhr, schrieb Jim Fulton <j...@zope.com>: > >> This wouldn't work. You would need to re-execute the suite >> for each retry. It's not enough to just keep committing the same >> transaction. (There are other details wrong with the code above, >> but they are fixable.) Python doesn't provide a way to keep >> executing the suite. > > You are right. > > The only thing I could come up with was something like below, using a > decorator instead of a context. > > -Matthias > > @doTransaction(count = 5) > def storeData(): > ... store data here ... > > def doTransaction(transaction = None, count = 3): > def decorator(func): > def do(): > for i in range(1+count): > try: > func() > except: > transaction.abort() > raise > try: > transaction.commit() > except ConflictError: > if i == count: > raise > else: > return > return do
This should read return do(), i.e. the decorator should directly execute the storeData function. All in all I think Benji's proposal looks better :-) -Matthias _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev