repoze.tm2 API

class repoze.tm.TM(application, commit_veto=None)

Transaction management WSGI middleware

TM.commit()
TM.abort()
class repoze.tm.AfterEnd

Callback registry API helper class. Use the singleton instance repoze.tm.after_end when possible.

AfterEnd.register(func, txn)
AfterEnd.unregister(func, txn)
AfterEnd.cleanup(txn)
repoze.tm.isActive(environ)

Return True if the repoze.tm.active key is in the WSGI environment passed as environ, otherwise return False.

repoze.tm.default_commit_veto(environ, status, headers)

When used as a commit veto, the logic in this function will cause the transaction to be committed if:

  • An X-Tm header with the value commit exists.

If an X-Tm header with the value commit does not exist, the transaction will be aborted, if:

  • An X-Tm header with the value abort (or any value other than commit) exists.

  • An X-Tm-Abort header exists with any value (for backwards compatibility; prefer X-Tm=abort in new code).

  • The status code starts with 4 or 5.

Otherwise the transaction will be committed by default.

tm.after_end = <repoze.tm.AfterEnd object>