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():

                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
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to