Kudos to whomever turned the "transaction" package's transaction manager
into a context manager and was thoughtful enough to provide the
"attempts" method (which returns a separate context manager, wrapping
the txn context manager, and retries some number of configurable times).
This makes writing code that integrates with a web system that commits
or aborts as easy as:

         import transaction

         for attempt in transaction.attempts(attempts):
            with attempt as t:
                response = handler(request)

                if t.isDoomed():
                    t.abort()

                if commit_veto is not None:
                    veto = commit_veto(request, response)
                    veto and t.abort()

                return response

Very nice.

- C


_______________________________________________
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 )

Reply via email to