Set up am implicit ‘tween’ to do transaction management using the
transactionpackage. The tween will be slotted between the main Pyramid app and the Pyramid exception view handler.
For every request it handles, the tween will begin a transaction by calling
transaction.begin(), and will then call the downstream handler (usually the main Pyramid application request handler) to obtain a response. When attempting to call the downstream handler:
- If an exception is raised by downstream handler while attempting to
obtain a response, the transaction will be rolled back
transaction.abort()will be called).
- If no exception is raised by the downstream handler, but the
transaction is doomed (
transaction.doom()has been called), the transaction will be rolled back.
- If the deployment configuration specifies a
tm.commit_vetosetting, and the transaction management tween receives a response from the downstream handler, the commit veto hook will be called. If it returns True, the transaction will be rolled back. If it returns False, the transaction will be committed.
- If none of the above conditions are True, the transaction will be
- If an exception is raised by downstream handler while attempting to obtain a response, the transaction will be rolled back (
When used as a commit veto, the logic in this function will cause the transaction to be aborted if:
X-Tmresponse header with the value
abort(or any value other than
- The response status code starts with
Otherwise the transaction will be allowed to commit.