- Drop support for Python 3.7, and 3.8.
- Add support for Python 3.11, 3.12, and 3.13.
- rename "master" to "main"
- Fix retrying transactions with pyramid_retry when using veto and a datamanger marks the exception as retryable.
- Drop support for Python 2.7, 3.4, 3.5, and 3.6.
- Add support for Python 3.8, 3.9, and 3.10.
- Blackify project source.
- Allow overriding
pyramid_tm
via the environ for testing purposes. See #72 - When
tm.annotate_user
is enabled, userequest.authenticated_userid
instead ofrequest.unauthenticated_userid
. The latter is deprecated in Pyramid 2.0. See #72
- Mark all
transaction.interfaces.TransientError
exceptions automatically as retryable bypyramid_retry
if it is installed. See #71
- Support Python 3.7.
- Fix error handling when using
transaction >= 2.4.0
. See #68
This is a backward-incompatible change for anyone using the
tm.commit_veto
hook. Anyone else is unaffected.The
tm.commit_veto
hook will now be consulted for any squashed exceptions instead of always aborting. Previously, if an exception was handled by an exception view, the transaction would always be aborted. Now, thecommit_veto
can inspectrequest.exception
and the generatedresponse
to determine whether to commit or abort.The new behavior when using the
pyramid_tm.default_commit_veto
is that a squashed exception may be committed if either of the following conditions are true:- The response contains the
x-tm
header set tocommit
. - The response's status code does not start with
4
or5
.
In most cases the response would result in 4xx or 5xx exception and would be aborted - this behavior remains the same. However, if the squashed exception rendered a response that is 3xx or 2xx (such as raising
pyramid.httpexceptions.HTTPFound
), then the transaction will be committed instead of aborted.See #65
- The response contains the
- On Pyramid >= 1.7 any errors raised from
pyramid_tm
invokingrequest.tm.abort
andrequest.tm.commit
will be caught and used to lookup and execute an exception view to return an error response. This exception view will be executed with an inactive transaction manager. See #61
- The
pyramid_tm
tween has been moved over theEXCVIEW
tween. This means the transaction is open during exception view execution. See #55 - Added a
pyramid_tm.is_tm_active
and atm_active
view predicate which may be useful in exception views that require access to the database. See #60
- The
tm.attempts
setting has been removed and retry support has been moved into a new package namedpyramid_retry
. If you want retry support then please look at that library for more information about installing and enabling it. See #55 - The
pyramid_tm
tween has been moved over theEXCVIEW
tween. If you have any hacks in your application that are opening a new transaction inside your exception views then it's likely you will want to remove them or re-evaluate when upgrading. See #55 - Drop support for Pyramid < 1.5.
- Support for Python 3.6.
pyramid_tm
1.1.0 failed to fix a unicode issue related to undecodable request paths. The placeholder message was not unicode. See #52- Include Changes in the main docs.
- Support
transaction
2.x. - The transaction's request path and userid are now coerced to unicode by
first decoding as
utf-8
and falling back tolatin-1
. If the userid does not conform to these restrictions then settm.annotate_user = no
in your settings. See #50
- Pin to
transaction < 1.99
as pyramid_tm is currently incompatible with the new 2.x release of transaction. See #49
- Removes the
AttributeError
whenrequest.tm
is accessed outside the tween. It turns out this broke subrequests as well aspshell
andpyramid.paster.bootstrapp
CLI scripts, especially when using the global transaction manager which can be tracked outside of the tween. See #48
- Drop Python 2.6, 3.2 and 3.3 support.
- Add Python 3.5 support.
- Subtle bugs can occur if you use the transaction manager during a request
in which
pyramid_tm
is disabled via anactivate_hook
. To combat these types of errors, attempting to accessrequest.tm
will now raise anAttributeError
whenpyramid_tm
is inactive. See #46
- Fix compatibility with 1.2 and 1.3 again. This wasn't fully fixed in the 0.12 release as the tween was relying on request properties working (which they do not inside tweens in older versions). See #39
- Expose a
tm.annotate_user
option to avoid computingrequest.unauthenticated_userid
on every request. See #36 - Restore compatibility with Pyramid 1.2 and 1.3.
- Add a hook to override creation of the transaction manager (the default
remains the thread-local one accessed through
transaction.manager
). See: #31
- Fix recording transactions with non-text, non-bytes userids. See: #28
- Work around recording transaction userid containing unicode. See #15, although the fix is different, to ensure Python3 compatibility.
- Work around recording transaction notes containing unicode. #25
- Add a new
tm.activate_hook
hook which can control when the transaction manager is active. For example, this may be useful in situations where the manager should be disabled for a particular URL. #12 - Fix unit tests under Pyramid 1.5.
- Fix a bug preventing retryable exceptions from actually being retried. #8
- Don't call
setUser
on transaction if there is no user logged in. This could cause the username set on the transaction to be a strange string: " None". #9 - Avoid crash when the
path_info
cannot be decoded from the request object. #19
- Write unauthenticated userid and
request.path_info
as transaction metadata viat.setUser
andt.note
respectively during a commit.
- Disuse the confusing and bug-ridden generator-plus-context-manager "attempts" mechanism from the transaction package for retrying retryable exceptions (e.g. ZODB ConflictError). Use a simple while loop plus a counter and imperative logic instead.
- When a non-retryable exception was raised as the result of a call to
transaction.manager.commit
, the exception was not reraised properly. Symptom: an unrecoverable exception such asUnsupported: Storing blobs in <somestorage> is not supported.
would be swallowed inappropriately.
- Work around failure to retry ConflictError properly at commit time by the
transaction
1.2.0 package. See https://mail.zope.org/pipermail/zodb-dev/2012-March/014603.html for details.
- No longer tested under Python 2.5 by
tox.ini
(and therefore no longer tested under 2.5 by the Pylons Jenkins server). The package may still work under 2.5, but automated tests will no longer show breakage when it changes in ways that break 2.5 support. - Squash test deprecation warnings under Python 3.2.
- The transaction manager has been converted to a Pyramid 1.2 "tween" (instead of an event subscriber). It will be slotted directly "below" the exception view handler, meaning it will have a chance to handle exceptions before they are turned into responses. This means it's best to "raise HTTPFound(...)" instead of "return HTTPFound(...)" if you want an HTTP exception to abort the transaction.
- The transaction manager will now retry retryable exceptions (such as a ZODB
conflict error) if
tm.attempts
is configured to be more than the default of1
. See theRetrying
section of the documentation. - Python 3.2 compatibility (requires Pyramid 1.3dev+).
Incompatible with Pyramid < 1.2a1. Use
pyramid_tm
version 0.2 if you need compatibility with an older Pyramid installation.The
default_commit_veto
commit veto callback is no longer configured into the system by default. Usetm.commit_veto = pyramid_tm.default_commit_veto
in the deployment settings to add it. This is for parity withrepoze.tm2
, which doesn't configure in a commit veto by default either.The
default_commit_veto
no longer checks for the presence of theX-Tm-Abort
header when attempting to figure out whether the transaction should be aborted (although it still checks for theX-Tm
header). Use version 0.2 or a custom commit veto function if your application depends on theX-Tm-Abort
header.A commit veto is now called with two arguments:
request
andresponse
. Therequest
is the webob request that caused the transaction manager to become active. Theresponse
is the response returned by the Pyramid application. This call signature is incompatible with older versions. The call signature of apyramid_tm
0.2 and older commit veto accepted three arguments:environ
,status
, andheaders
. If you're using a customcommit_veto
function, you'll need to either convert your existing function to use the new calling convention or use a wrapper to make it compatible with the new calling convention. Here's a simple wrapper function (bwcompat_commit_veto_wrapper
) that will allow you to use your existing custom commit veto function:def bwcompat_commit_veto_wrapper(request, response): return my_custom_commit_veto(request.environ, response.status, response.headerlist)
- The
pyramid_tm.commit_veto
configuration setting is now canonically spelled astm.commit_veto
. The older spelling will continue to work, but may raise a deprecation error when used.
- A new header
X-Tm
is now honored by thedefault_commit_veto
commit veto hook. If this header exists in the headerlist, its value must be a string. If its value iscommit
, the transaction will be committed regardless of the status code or the value ofX-Tm-Abort
. If the value of theX-Tm
header isabort
(or any other string value exceptcommit
), the transaction will be aborted, regardless of the status code or the value ofX-Tm-Abort
.
- Initial release, based on repoze.tm2