<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello retry shall be made on a transaction basis.<br>
<br>
I would say, that while for the regular_view retry may be handled by a<br>
middleware or such (the publisher in Zope2 ?), you may want to manage it<br>
in my_view around your transaction.<br>
<br>
in my_view you do transaction commit, so you won&#39;t undo the<br>
slow_no_conflict part if you fail in the second part (if it was not your<br>
intent you shall use subtransactions).<br>
<br>
So you may do something like :<br>
<br>
from ZODB.POSException import ConflictError<br>
<br>
def my_view(request):<br>
<br>
     transaction.begin()<br>
     slow_no_conflict()<br>
     transaction.commit()<br>
<br>
     do_retry = True<br>
     while do_retry:<br>
        try:<br>
           transaction.begin()<br>
           fast_yes_conflict(avar)<br>
           transaction.commit()<br>
           do_retry = False<br>
        except Exception, e:<br>
           transaction.abort()<br>
           do_retry = isinstance(e, ConflictError)<br>
<br>
<br>
Hope this helps !<br></blockquote><div><br></div><div>That does help, thanks! Makes a lot of sense, too. Question - will hooks added with `addAfterCommitHook()` be called</div><div>if a transaction is aborted? Also, in what situation is a web request retried automatically - is it if</div>
<div>the function handling the request raises a ConflictError (e.g. by not catching a .commit() that fails)?<br><br>Thanks,</div><div>- Claudiu</div></div>