>
> Hello retry shall be made on a transaction basis.
>
> I would say, that while for the regular_view retry may be handled by a
> middleware or such (the publisher in Zope2 ?), you may want to manage it
> in my_view around your transaction.
>
> in my_view you do transaction commit, so you won't undo the
> slow_no_conflict part if you fail in the second part (if it was not your
> intent you shall use subtransactions).
>
> So you may do something like :
>
> from ZODB.POSException import ConflictError
>
> def my_view(request):
>
>     transaction.begin()
>     slow_no_conflict()
>     transaction.commit()
>
>     do_retry = True
>     while do_retry:
>        try:
>           transaction.begin()
>           fast_yes_conflict(avar)
>           transaction.commit()
>           do_retry = False
>        except Exception, e:
>           transaction.abort()
>           do_retry = isinstance(e, ConflictError)
>
>
> Hope this helps !
>

That does help, thanks! Makes a lot of sense, too. Question - will hooks
added with `addAfterCommitHook()` be called
if a transaction is aborted? Also, in what situation is a web request
retried automatically - is it if
the function handling the request raises a ConflictError (e.g. by not
catching a .commit() that fails)?

Thanks,
- Claudiu
_______________________________________________
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to