Registry / web-framework / pyramid-tm

pyramid-tm

JSON →
library2.6pypypiunverified

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-tm
INSTALL
IMPORT
SIG · PYRAMID-TM
P
pyramid-tm
web-frameworkpythonv2.6
Install
3.0s avg
Import
Disk
27MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 24MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.0s · import 0.000s · 25MB
27MB installed
● package 27MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pyramid_tm
config.include('pyramid_tm')
Include the package in your Pyramid application's configuration.

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.

from wsgiref.simple_server import make_server from pyramid.config import Configurator from pyramid.response import Response def hello_world(request): # Any database operations here would automatically join the active transaction return Response('Hello World from pyramid_tm!') if __name__ == '__main__': with Configurator() as config: config.include('pyramid_tm') # Enable pyramid_tm config.add_route('hello', '/') config.add_view(hello_world, route_name='hello') app = config.make_wsgi_app() server = make_server('0.0.0.0', 6543, app) print("Pyramid server running on http://0.0.0.0:6543") server.serve_forever()
Debug
Known issues
breakingVersion 2.6 dropped support for Python 3.7 and 3.8. Ensure your environment uses Python 3.9 or newer.
fix
Upgrade your Python environment to 3.9 or later, or use an older `pyramid-tm` version compatible with your Python runtime.
affects: >=2.6
breakingThe behavior of the `tm.commit_veto` hook changed in version 2.2. It will now be consulted for squashed exceptions (exceptions handled by an exception view) instead of always aborting. It inspects `request.exception` and the response to determine whether to commit or abort.
fix
Review and update any custom `tm.commit_veto` implementations to account for the new behavior regarding squashed exceptions.
affects: >=2.2
gotchaAccessing `request.tm` outside the `pyramid_tm` tween or during a request where `pyramid_tm` was explicitly disabled (e.g., via an activate hook or `tm.active` in WSGI environ for testing) will raise an `AttributeError`.
fix
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.
affects: All
gotchaIf you manually complete a transaction using `request.tm.abort()` or `request.tm.commit()`, subsequent uses of the transaction manager within the same request will fail unless `request.tm.begin()` is explicitly invoked again to start a new transaction.
fix
After explicit `abort()` or `commit()`, call `request.tm.begin()` if further transaction-managed operations are required within the same request cycle.
affects: All
gotchaIf `repoze.tm` or `repoze.tm2` middleware is present in the WSGI pipeline, `pyramid_tm` becomes inactive. These middlewares handle transaction management themselves and conflict with `pyramid_tm`.
fix
Remove `repoze.tm` or `repoze.tm2` from your WSGI pipeline if you intend to use `pyramid_tm` for transaction management.
affects: All
Upgrade
Version history
2.6latest on PyPI · released Nov 14, 2024
Audit
Dependencies
pyramidrequiredCore web framework integration.
transactionrequiredProvides the underlying transaction management system.
pyramid_retryoptionalEnhances retryable exception handling for transactions (optional).
zope.sqlalchemyoptionalIntegration with SQLAlchemy sessions for transaction management (optional).
Agent activity
11 hits · last 30 days
node
8
Amazon
1
Resources
pyramid-tm — pip install pyramid-tm · libregistry