pyramid_tm is a package that integrates the Python `transaction` package with the Pyramid web framework, allowing Pyramid requests to join the active transaction. It provides centralized transaction management for Pyramid applications without relying on external WSGI middleware. Maintained by the Pylons Project, it has a generally active release cadence, with version 2.6 released in November 2024.
pip install pyramid-tmVerified import paths — ran on the pinned version, not inferred.
This minimal Pyramid application demonstrates how to include `pyramid_tm`. Once included, any operations involving data managers (like ZODB or SQLAlchemy with `zope.sqlalchemy`) will automatically join the transaction associated with the request.
Upgrade your Python environment to 3.9 or later, or use an older `pyramid-tm` version compatible with your Python runtime.
Review and update any custom `tm.commit_veto` implementations to account for the new behavior regarding squashed exceptions.
Ensure `request.tm` is only accessed within the context where the `pyramid_tm` tween is active. For testing, set `tm.active` in the WSGI environ to `False` to disable it, or `tm.manager` to provide your own transaction manager.
After explicit `abort()` or `commit()`, call `request.tm.begin()` if further transaction-managed operations are required within the same request cycle.
Remove `repoze.tm` or `repoze.tm2` from your WSGI pipeline if you intend to use `pyramid_tm` for transaction management.