pyramid-tm 2.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyramid_tm/__init__.py ADDED
@@ -0,0 +1,305 @@
1
+ from pyramid.exceptions import ConfigurationError, NotFound
2
+ from pyramid.settings import asbool
3
+ from pyramid.tweens import EXCVIEW
4
+ from pyramid.util import DottedNameResolver
5
+ import sys
6
+ import transaction
7
+ import warnings
8
+ import zope.interface
9
+
10
+ try:
11
+ from pyramid_retry import IRetryableError
12
+ except ImportError: # pragma: no cover
13
+ IRetryableError = zope.interface.Interface
14
+
15
+ try:
16
+ from pyramid_retry import mark_error_retryable
17
+ except ImportError: # pragma: no cover
18
+ mark_error_retryable = lambda error: None
19
+
20
+ mark_error_retryable(transaction.interfaces.TransientError)
21
+
22
+ resolver = DottedNameResolver(None)
23
+
24
+
25
+ def default_commit_veto(request, response):
26
+ """
27
+ When used as a commit veto, the logic in this function will cause the
28
+ transaction to be aborted if:
29
+
30
+ - An ``X-Tm`` response header with the value ``abort`` (or any value
31
+ other than ``commit``) exists.
32
+
33
+ - The response status code starts with ``4`` or ``5``.
34
+
35
+ Otherwise the transaction will be allowed to commit.
36
+ """
37
+ xtm = response.headers.get('x-tm')
38
+ if xtm is not None:
39
+ return xtm != 'commit'
40
+ return response.status.startswith(('4', '5'))
41
+
42
+
43
+ class AbortWithResponse(Exception):
44
+ """Abort the transaction but return a pre-baked response."""
45
+
46
+ def __init__(self, response):
47
+ self.response = response
48
+
49
+
50
+ def tm_tween_factory(handler, registry):
51
+ settings = registry.settings
52
+ maybe_resolve = lambda val: resolver.maybe_resolve(val) if val else None
53
+ old_commit_veto = settings.get('pyramid_tm.commit_veto', None)
54
+ commit_veto = settings.get('tm.commit_veto', old_commit_veto)
55
+ activate_hook = settings.get('tm.activate_hook')
56
+ commit_veto = maybe_resolve(commit_veto)
57
+ activate_hook = maybe_resolve(activate_hook)
58
+ annotate_user = asbool(settings.get('tm.annotate_user', True))
59
+
60
+ if 'tm.attempts' in settings: # pragma: no cover
61
+ warnings.warn(
62
+ 'pyramid_tm removed support for the "tm.attempts" '
63
+ 'setting in version 2.0. To re-enable retry support '
64
+ 'add pyramid_retry to your application.'
65
+ )
66
+
67
+ # define a finish function that we'll call from every branch to
68
+ # commit or abort the transaction - this can't be in a finally because
69
+ # we only want the finisher to wrap commit/abort which occur in several
70
+ # disparate branches below and we want to avoid catching errors from
71
+ # non commit/abort related operations
72
+ def _finish(request, finisher, response=None):
73
+ # ensure the manager is inactive prior to invoking the finisher
74
+ # such that when we handle any possible exceptions it is ready
75
+ environ = request.environ
76
+ if 'tm.active' in environ:
77
+ del environ['tm.active']
78
+ if 'tm.manager' in environ:
79
+ del environ['tm.manager']
80
+
81
+ try:
82
+ finisher()
83
+
84
+ # catch any errors that occur specifically during commit/abort
85
+ # and attempt to render them to a response
86
+ except Exception:
87
+ exc_info = sys.exc_info()
88
+ try:
89
+ if hasattr(request, 'invoke_exception_view'): # pyramid >= 1.7
90
+ response = request.invoke_exception_view(exc_info)
91
+
92
+ else: # pragma: no cover
93
+ raise NotFound
94
+
95
+ except NotFound:
96
+ # since commit/abort has already been executed it's highly
97
+ # likely we will not detect any backend-specific retryable
98
+ # issues here unless they directly subclass TransientError
99
+ # since the manager has cleared its list of data mangers at
100
+ # this point
101
+ maybe_tag_retryable(request, exc_info)
102
+ raise exc_info[1] from None
103
+
104
+ finally:
105
+ del exc_info # avoid leak
106
+
107
+ return response
108
+
109
+ def tm_tween(request):
110
+ environ = request.environ
111
+ if (
112
+ # don't handle txn mgmt if repoze.tm is in the WSGI pipeline
113
+ 'repoze.tm.active' in environ
114
+ or
115
+ # pyramid_tm should only be active once
116
+ 'tm.active' in environ
117
+ or
118
+ # check activation hooks
119
+ activate_hook is not None
120
+ and not activate_hook(request)
121
+ ):
122
+ return handler(request)
123
+
124
+ # grab a reference to the manager
125
+ manager = request.tm
126
+
127
+ # mark the environ as being managed by pyramid_tm
128
+ environ['tm.active'] = True
129
+ environ['tm.manager'] = manager
130
+
131
+ t = manager.begin()
132
+
133
+ try:
134
+ # do not address the authentication policy until we are within
135
+ # the transaction boundaries
136
+ if annotate_user:
137
+ userid = request.authenticated_userid
138
+ if userid:
139
+ t.user = str(userid)
140
+ try:
141
+ t.note(request.path_info)
142
+ except UnicodeDecodeError:
143
+ t.note("Unable to decode path as unicode")
144
+
145
+ response = handler(request)
146
+ if manager.isDoomed():
147
+ raise AbortWithResponse(response)
148
+
149
+ if commit_veto is not None:
150
+ if commit_veto(request, response):
151
+ raise AbortWithResponse(response)
152
+
153
+ # check for a squashed exception and handle it
154
+ # this would happen if an exception view was invoked and
155
+ # rendered an error response
156
+ exc_info = getattr(request, 'exc_info', None)
157
+ if exc_info is not None:
158
+ maybe_tag_retryable(request, exc_info)
159
+ if commit_veto is None:
160
+ raise AbortWithResponse(response)
161
+
162
+ return _finish(request, manager.commit, response)
163
+
164
+ except AbortWithResponse as e:
165
+ return _finish(request, manager.abort, e.response)
166
+
167
+ # an unhandled exception was propagated - we should abort the
168
+ # transaction and re-raise the original exception
169
+ except Exception as exc:
170
+ # try to tag the original exception as retryable before
171
+ # aborting the transaction because after abort it may not
172
+ # be possible to determine if the exception is retryable
173
+ # because the bound data managers are cleared
174
+ maybe_tag_retryable(request, sys.exc_info())
175
+
176
+ exc_response = _finish(request, manager.abort)
177
+ if exc_response is not None:
178
+ return exc_response
179
+ raise exc from None
180
+
181
+ return tm_tween
182
+
183
+
184
+ def explicit_manager(request):
185
+ """
186
+ Create a new ``transaction.TransactionManager`` in explicit mode.
187
+
188
+ This is recommended transaction manager and will help to weed out errors
189
+ caused by code that tweaks the transaction before it has begun or after
190
+ it has ended.
191
+
192
+ """
193
+ return transaction.TransactionManager(explicit=True)
194
+
195
+
196
+ def maybe_tag_retryable(request, exc_info):
197
+ exc = exc_info[1]
198
+ txn = request.tm.get()
199
+ if hasattr(txn, 'isRetryableError'):
200
+ if txn.isRetryableError(exc):
201
+ zope.interface.alsoProvides(exc, IRetryableError)
202
+
203
+ # bw-compat transaction < 2.4
204
+ elif hasattr(request.tm, '_retryable'): # pragma: no cover
205
+ if request.tm._retryable(*exc_info[:-1]):
206
+ zope.interface.alsoProvides(exc, IRetryableError)
207
+
208
+
209
+ def create_tm(request):
210
+ manager = request.environ.get('tm.manager')
211
+ if manager:
212
+ return manager
213
+
214
+ manager_hook = request.registry.settings.get('tm.manager_hook')
215
+ if manager_hook:
216
+ manager_hook = resolver.maybe_resolve(manager_hook)
217
+ return manager_hook(request)
218
+
219
+ return transaction.manager
220
+
221
+
222
+ def is_tm_active(request):
223
+ """
224
+ Return ``True`` if the ``request`` is currently being managed by
225
+ the pyramid_tm tween. If ``False`` then it may be necessary to manage
226
+ transactions yourself.
227
+
228
+ .. note::
229
+
230
+ This does **not** indicate that there is a current transaction. For
231
+ example, ``request.tm.get()`` may raise a ``NoTransaction`` error even
232
+ though ``is_tm_active`` returns ``True``. This would be caused by user
233
+ code that manually completed a transaction and did not begin a new one.
234
+ """
235
+ return request.environ.get('tm.active', False)
236
+
237
+
238
+ class TMActivePredicate(object):
239
+ """
240
+ A :term:`view predicate` registered as ``tm_active``. Can be used
241
+ to determine if an exception view should execute based on whether it's
242
+ the last retry attempt before aborting the request.
243
+
244
+ .. seealso:: See :func:`pyramid_tm.is_tm_active`.
245
+
246
+ """
247
+
248
+ def __init__(self, val, config):
249
+ if not isinstance(val, bool):
250
+ raise ConfigurationError(
251
+ 'The "tm_active" view predicate value must be '
252
+ 'True or False.',
253
+ )
254
+ self.val = val
255
+
256
+ def text(self):
257
+ return 'tm_active = %s' % (self.val,)
258
+
259
+ phash = text
260
+
261
+ def __call__(self, context, request):
262
+ is_active = is_tm_active(request)
263
+ return (self.val and is_active) or (not self.val and not is_active)
264
+
265
+
266
+ def includeme(config):
267
+ """
268
+ Set up an implicit 'tween' to do transaction management using the
269
+ ``transaction`` package. The tween will be slotted between the Pyramid
270
+ request ingress and the Pyramid exception view handler.
271
+
272
+ For every request it handles, the tween will begin a transaction by
273
+ calling ``request.tm.begin()``, and will then call the downstream
274
+ handler (usually the main Pyramid application request handler) to obtain
275
+ a response. When attempting to call the downstream handler:
276
+
277
+ - If an exception is raised by downstream handler while attempting to
278
+ obtain a response, the transaction will be rolled back
279
+ (``request.tm.abort()`` will be called).
280
+
281
+ - If no exception is raised by the downstream handler, but the
282
+ transaction is doomed (``request.tm.doom()`` has been called), the
283
+ transaction will be rolled back.
284
+
285
+ - If the deployment configuration specifies a ``tm.commit_veto`` setting,
286
+ and the transaction management tween receives a response from the
287
+ downstream handler, the commit veto hook will be called. If it returns
288
+ True, the transaction will be rolled back. If it returns ``False``, the
289
+ transaction will be committed.
290
+
291
+ - If none of the above conditions are true, the transaction will be
292
+ committed (via ``request.tm.commit()``).
293
+
294
+ """
295
+ config.add_tween('pyramid_tm.tm_tween_factory', over=EXCVIEW)
296
+ config.add_request_method(create_tm, name='tm', reify=True)
297
+ config.add_view_predicate('tm_active', TMActivePredicate)
298
+
299
+ def ensure():
300
+ manager_hook = config.registry.settings.get("tm.manager_hook")
301
+ if manager_hook is not None:
302
+ manager_hook = resolver.maybe_resolve(manager_hook)
303
+ config.registry.settings["tm.manager_hook"] = manager_hook
304
+
305
+ config.action(None, ensure, order=10)
@@ -0,0 +1,38 @@
1
+ A copyright notice accompanies this license document that identifies
2
+ the copyright holders.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ 1. Redistributions in source code must retain the accompanying
9
+ copyright notice, this list of conditions, and the following
10
+ disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the accompanying
13
+ copyright notice, this list of conditions, and the following
14
+ disclaimer in the documentation and/or other materials provided
15
+ with the distribution.
16
+
17
+ 3. Names of the copyright holders must not be used to endorse or
18
+ promote products derived from this software without prior
19
+ written permission from the copyright holders.
20
+
21
+ 4. If any files are modified, you must cause the modified files to
22
+ carry prominent notices stating that you changed the files and
23
+ the date of any change.
24
+
25
+ Disclaimer
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND
28
+ ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31
+ HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
33
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
35
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
37
+ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38
+ SUCH DAMAGE.
@@ -0,0 +1,419 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyramid_tm
3
+ Version: 2.6
4
+ Summary: A package which allows Pyramid requests to join the active transaction
5
+ Home-page: https://github.com/Pylons/pyramid_tm
6
+ Author: Rocky Burt, Chris McDonough
7
+ Author-email: pylons-discuss@googlegroups.com
8
+ Maintainer: Pylons Project
9
+ Maintainer-email: pylons-discuss@googlegroups.com
10
+ License: BSD-derived (Repoze)
11
+ Project-URL: Documentation, https://docs.pylonsproject.org/projects/pyramid-tm/en/latest/index.html
12
+ Project-URL: Changelog, https://docs.pylonsproject.org/projects/pyramid-tm/en/latest/changes.html
13
+ Project-URL: Issue Tracker, https://github.com/Pylons/pyramid_tm/issues
14
+ Keywords: wsgi pylons pyramid transaction
15
+ Classifier: Development Status :: 6 - Mature
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
26
+ Classifier: Operating System :: OS Independent
27
+ Classifier: Framework :: Pyramid
28
+ Classifier: License :: Repoze Public License
29
+ Requires-Python: >=3.9
30
+ Description-Content-Type: text/x-rst
31
+ License-File: LICENSE.txt
32
+ Requires-Dist: pyramid>=1.5
33
+ Requires-Dist: transaction>=2.0
34
+ Provides-Extra: docs
35
+ Requires-Dist: Sphinx>=1.8.1; extra == "docs"
36
+ Requires-Dist: pylons-sphinx-themes>=1.0.9; extra == "docs"
37
+ Provides-Extra: testing
38
+ Requires-Dist: WebTest; extra == "testing"
39
+ Requires-Dist: pytest; extra == "testing"
40
+ Requires-Dist: pytest-cov; extra == "testing"
41
+ Requires-Dist: coverage>=5.0; extra == "testing"
42
+
43
+ ``pyramid_tm``
44
+ ==============
45
+
46
+ .. image:: https://github.com/Pylons/pyramid_tm/actions/workflows/ci-tests.yml/badge.svg?branch=main
47
+ :target: https://github.com/Pylons/pyramid_tm/actions/workflows/ci-tests.yml?query=branch%3Amain
48
+ :alt: main CI Status
49
+
50
+
51
+ .. image:: https://readthedocs.org/projects/pyramid-tm/badge/?version=latest
52
+ :target: https://docs.pylonsproject.org/projects/pyramid-tm/en/latest/
53
+ :alt: Documentation Status
54
+
55
+ ``pyramid_tm`` is a package which allows Pyramid requests to join
56
+ the active transaction as provided by the `transaction
57
+ <https://pypi.org/project/transaction/>`_ package.
58
+
59
+ See `https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/
60
+ <https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/>`_
61
+ or ``docs/index.rst`` in this distribution for detailed
62
+ documentation.
63
+
64
+ Changes
65
+ -------
66
+
67
+ 2.6 (2024-11-14)
68
+ ^^^^^^^^^^^^^^^^
69
+
70
+ - Drop support for Python 3.7, and 3.8.
71
+
72
+ - Add support for Python 3.11, 3.12, and 3.13.
73
+
74
+ - rename "master" to "main"
75
+
76
+ - Fix retrying transactions with `pyramid_retry` when using veto and a datamanger
77
+ marks the exception as retryable.
78
+
79
+ 2.5 (2022-03-12)
80
+ ^^^^^^^^^^^^^^^^
81
+
82
+ - Drop support for Python 2.7, 3.4, 3.5, and 3.6.
83
+
84
+ - Add support for Python 3.8, 3.9, and 3.10.
85
+
86
+ - Blackify project source.
87
+
88
+ 2.4 (2020-01-06)
89
+ ^^^^^^^^^^^^^^^^
90
+
91
+ - Allow overriding ``pyramid_tm`` via the environ for testing purposes.
92
+ See https://github.com/Pylons/pyramid_tm/pull/72
93
+
94
+ - When ``tm.annotate_user`` is enabled, use ``request.authenticated_userid``
95
+ instead of ``request.unauthenticated_userid``. The latter is deprecated in
96
+ Pyramid 2.0.
97
+ See https://github.com/Pylons/pyramid_tm/pull/72
98
+
99
+ 2.3 (2019-09-30)
100
+ ^^^^^^^^^^^^^^^^
101
+
102
+ - Mark all ``transaction.interfaces.TransientError`` exceptions
103
+ automatically as retryable by ``pyramid_retry`` if it is installed.
104
+ See https://github.com/Pylons/pyramid_tm/pull/71
105
+
106
+ 2.2.1 (2018-10-23)
107
+ ^^^^^^^^^^^^^^^^^^
108
+
109
+ - Support Python 3.7.
110
+
111
+ - Fix error handling when using ``transaction >= 2.4.0``.
112
+ See https://github.com/Pylons/pyramid_tm/pull/68
113
+
114
+ 2.2 (2017-07-03)
115
+ ^^^^^^^^^^^^^^^^
116
+
117
+ Backward Incompatibilities
118
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
119
+
120
+ - This is a backward-incompatible change for anyone using the
121
+ ``tm.commit_veto`` hook. Anyone else is unaffected.
122
+
123
+ The ``tm.commit_veto`` hook will now be consulted for any squashed
124
+ exceptions instead of always aborting. Previously, if an exception
125
+ was handled by an exception view, the transaction would always be aborted.
126
+ Now, the ``commit_veto`` can inspect ``request.exception`` and the generated
127
+ ``response`` to determine whether to commit or abort.
128
+
129
+ The new behavior when using the ``pyramid_tm.default_commit_veto`` is that
130
+ a squashed exception may be committed if either of the following conditions
131
+ are true:
132
+
133
+ - The response contains the ``x-tm`` header set to ``commit``.
134
+
135
+ - The response's status code does not start with ``4`` or ``5``.
136
+
137
+ In most cases the response would result in 4xx or 5xx exception and would
138
+ be aborted - this behavior remains the same. However, if the squashed
139
+ exception rendered a response that is 3xx or 2xx (such as raising
140
+ ``pyramid.httpexceptions.HTTPFound``), then the transaction will be
141
+ committed instead of aborted.
142
+
143
+ See https://github.com/Pylons/pyramid_tm/pull/65
144
+
145
+ 2.1 (2017-06-07)
146
+ ^^^^^^^^^^^^^^^^
147
+
148
+ - On Pyramid >= 1.7 any errors raised from ``pyramid_tm`` invoking
149
+ ``request.tm.abort`` and ``request.tm.commit`` will be caught and used
150
+ to lookup and execute an exception view to return an error response. This
151
+ exception view will be executed with an inactive transaction manager.
152
+ See https://github.com/Pylons/pyramid_tm/pull/61
153
+
154
+ 2.0 (2017-04-11)
155
+ ^^^^^^^^^^^^^^^^
156
+
157
+ Major Features
158
+ ~~~~~~~~~~~~~~
159
+
160
+ - The ``pyramid_tm`` tween has been moved **over** the ``EXCVIEW`` tween.
161
+ This means the transaction is open during exception view execution.
162
+ See https://github.com/Pylons/pyramid_tm/pull/55
163
+
164
+ - Added a ``pyramid_tm.is_tm_active`` and a ``tm_active`` view predicate
165
+ which may be useful in exception views that require access to the database.
166
+ See https://github.com/Pylons/pyramid_tm/pull/60
167
+
168
+ Backward Incompatibilities
169
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
170
+
171
+ - The ``tm.attempts`` setting has been removed and retry support has been moved
172
+ into a new package named ``pyramid_retry``. If you want retry support then
173
+ please look at that library for more information about installing and
174
+ enabling it. See https://github.com/Pylons/pyramid_tm/pull/55
175
+
176
+ - The ``pyramid_tm`` tween has been moved **over** the ``EXCVIEW`` tween.
177
+ If you have any hacks in your application that are opening a new transaction
178
+ inside your exception views then it's likely you will want to remove them
179
+ or re-evaluate when upgrading.
180
+ See https://github.com/Pylons/pyramid_tm/pull/55
181
+
182
+ - Drop support for Pyramid < 1.5.
183
+
184
+ Minor Features
185
+ ~~~~~~~~~~~~~~
186
+
187
+ - Support for Python 3.6.
188
+
189
+ 1.1.1 (2016-11-21)
190
+ ^^^^^^^^^^^^^^^^^^
191
+
192
+ - ``pyramid_tm`` 1.1.0 failed to fix a unicode issue related to undecodable
193
+ request paths. The placeholder message was not unicode.
194
+ See https://github.com/Pylons/pyramid_tm/pull/52
195
+
196
+ - Include Changes in the main docs.
197
+
198
+ 1.1.0 (2016-11-19)
199
+ ^^^^^^^^^^^^^^^^^^
200
+
201
+ - Support ``transaction`` 2.x.
202
+
203
+ - The transaction's request path and userid are now coerced to unicode by
204
+ first decoding as ``utf-8`` and falling back to ``latin-1``. If the userid
205
+ does not conform to these restrictions then set ``tm.annotate_user = no``
206
+ in your settings. See https://github.com/Pylons/pyramid_tm/pull/50
207
+
208
+ 1.0.2 (2016-11-18)
209
+ ^^^^^^^^^^^^^^^^^^
210
+
211
+ - Pin to ``transaction < 1.99`` as pyramid_tm is currently incompatible with
212
+ the new 2.x release of transaction.
213
+ See https://github.com/Pylons/pyramid_tm/issues/49
214
+
215
+ 1.0.1 (2016-10-24)
216
+ ^^^^^^^^^^^^^^^^^^
217
+
218
+ - Removes the ``AttributeError`` when ``request.tm`` is accessed outside the
219
+ tween. It turns out this broke subrequests as well as ``pshell`` and
220
+ ``pyramid.paster.bootstrapp`` CLI scripts, especially when using the
221
+ global transaction manager which can be tracked outside of the tween.
222
+ See https://github.com/Pylons/pyramid_tm/pull/48
223
+
224
+ 1.0 (2016-09-12)
225
+ ^^^^^^^^^^^^^^^^
226
+
227
+ - Drop Python 2.6, 3.2 and 3.3 support.
228
+
229
+ - Add Python 3.5 support.
230
+
231
+ - Subtle bugs can occur if you use the transaction manager during a request
232
+ in which ``pyramid_tm`` is disabled via an ``activate_hook``. To combat these
233
+ types of errors, attempting to access ``request.tm`` will now raise an
234
+ ``AttributeError`` when ``pyramid_tm`` is inactive.
235
+ See https://github.com/Pylons/pyramid_tm/pull/46
236
+
237
+ 0.12.1 (2015-11-25)
238
+ ^^^^^^^^^^^^^^^^^^^
239
+
240
+ - Fix compatibility with 1.2 and 1.3 again. This wasn't fully fixed in the
241
+ 0.12 release as the tween was relying on request properties working (which
242
+ they do not inside tweens in older versions).
243
+ See https://github.com/Pylons/pyramid_tm/pull/39
244
+
245
+ 0.12 (2015-05-20)
246
+ ^^^^^^^^^^^^^^^^^
247
+
248
+ - Expose a ``tm.annotate_user`` option to avoid computing
249
+ ``request.unauthenticated_userid`` on every request.
250
+ See https://github.com/Pylons/pyramid_tm/pull/36
251
+
252
+ - Restore compatibility with Pyramid 1.2 and 1.3.
253
+
254
+ 0.11 (2015-02-04)
255
+ ^^^^^^^^^^^^^^^^^
256
+
257
+ - Add a hook to override creation of the transaction manager (the default
258
+ remains the thread-local one accessed through ``transaction.manager``).
259
+ See: https://github.com/Pylons/pyramid_tm/pull/31
260
+
261
+ 0.10 (2015-01-06)
262
+ ^^^^^^^^^^^^^^^^^
263
+
264
+ - Fix recording transactions with non-text, non-bytes userids.
265
+ See: https://github.com/Pylons/pyramid_tm/issues/28
266
+
267
+ 0.9 (2014-12-30)
268
+ ^^^^^^^^^^^^^^^^
269
+
270
+ - Work around recording transaction userid containing unicode.
271
+ See https://github.com/Pylons/pyramid_tm/pull/15, although the fix
272
+ is different, to ensure Python3 compatibility.
273
+
274
+ - Work around recording transaction notes containing unicode.
275
+ https://github.com/Pylons/pyramid_tm/pull/25
276
+
277
+ 0.8 (2014-11-12)
278
+ ^^^^^^^^^^^^^^^^
279
+
280
+ - Add a new ``tm.activate_hook`` hook which can control when the
281
+ transaction manager is active. For example, this may be useful in
282
+ situations where the manager should be disabled for a particular URL.
283
+ https://github.com/Pylons/pyramid_tm/pull/12
284
+
285
+ - Fix unit tests under Pyramid 1.5.
286
+
287
+ - Fix a bug preventing retryable exceptions from actually being retried.
288
+ https://github.com/Pylons/pyramid_tm/pull/8
289
+
290
+ - Don't call ``setUser`` on transaction if there is no user logged in.
291
+ This could cause the username set on the transaction to be a strange
292
+ string: " None". https://github.com/Pylons/pyramid_tm/pull/9
293
+
294
+ - Avoid crash when the ``path_info`` cannot be decoded from the request
295
+ object. https://github.com/Pylons/pyramid_tm/pull/19
296
+
297
+ 0.7 (2012-12-30)
298
+ ^^^^^^^^^^^^^^^^
299
+
300
+ - Write unauthenticated userid and ``request.path_info`` as transaction
301
+ metadata via ``t.setUser`` and ``t.note`` respectively during a commit.
302
+
303
+ 0.6 (2012-12-26)
304
+ ^^^^^^^^^^^^^^^^
305
+
306
+ - Disuse the confusing and bug-ridden generator-plus-context-manager "attempts"
307
+ mechanism from the transaction package for retrying retryable exceptions
308
+ (e.g. ZODB ConflictError). Use a simple while loop plus a counter and
309
+ imperative logic instead.
310
+
311
+ 0.5 (2012-06-26)
312
+ ^^^^^^^^^^^^^^^^
313
+
314
+ Bug Fixes
315
+ ~~~~~~~~~
316
+
317
+ - When a non-retryable exception was raised as the result of a call to
318
+ ``transaction.manager.commit``, the exception was not reraised properly.
319
+ Symptom: an unrecoverable exception such as ``Unsupported: Storing blobs in
320
+ <somestorage> is not supported.`` would be swallowed inappropriately.
321
+
322
+ 0.4 (2012-03-28)
323
+ ^^^^^^^^^^^^^^^^
324
+
325
+ Bug Fixes
326
+ ~~~~~~~~~
327
+
328
+ - Work around failure to retry ConflictError properly at commit time by the
329
+ ``transaction`` 1.2.0 package. See
330
+ https://mail.zope.org/pipermail/zodb-dev/2012-March/014603.html for
331
+ details.
332
+
333
+ Testing
334
+ ~~~~~~~
335
+
336
+ - No longer tested under Python 2.5 by ``tox.ini`` (and therefore no longer
337
+ tested under 2.5 by the Pylons Jenkins server). The package may still work
338
+ under 2.5, but automated tests will no longer show breakage when it changes
339
+ in ways that break 2.5 support.
340
+
341
+ - Squash test deprecation warnings under Python 3.2.
342
+
343
+ 0.3 (2011-09-27)
344
+ ^^^^^^^^^^^^^^^^
345
+
346
+ Features
347
+ ~~~~~~~~
348
+
349
+ - The transaction manager has been converted to a Pyramid 1.2 "tween"
350
+ (instead of an event subscriber). It will be slotted directly "below" the
351
+ exception view handler, meaning it will have a chance to handle exceptions
352
+ before they are turned into responses. This means it's best to "raise
353
+ HTTPFound(...)" instead of "return HTTPFound(...)" if you want an HTTP
354
+ exception to abort the transaction.
355
+
356
+ - The transaction manager will now retry retryable exceptions (such as a ZODB
357
+ conflict error) if ``tm.attempts`` is configured to be more than the
358
+ default of ``1``. See the ``Retrying`` section of the documentation.
359
+
360
+ - Python 3.2 compatibility (requires Pyramid 1.3dev+).
361
+
362
+ Backwards Incompatibilities
363
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
364
+
365
+ - Incompatible with Pyramid < 1.2a1. Use ``pyramid_tm`` version 0.2 if you
366
+ need compatibility with an older Pyramid installation.
367
+
368
+ - The ``default_commit_veto`` commit veto callback is no longer configured
369
+ into the system by default. Use ``tm.commit_veto =
370
+ pyramid_tm.default_commit_veto`` in the deployment settings to add it.
371
+ This is for parity with ``repoze.tm2``, which doesn't configure in a commit
372
+ veto by default either.
373
+
374
+ - The ``default_commit_veto`` no longer checks for the presence of the
375
+ ``X-Tm-Abort`` header when attempting to figure out whether the transaction
376
+ should be aborted (although it still checks for the ``X-Tm`` header). Use
377
+ version 0.2 or a custom commit veto function if your application depends on
378
+ the ``X-Tm-Abort`` header.
379
+
380
+ - A commit veto is now called with two arguments: ``request`` and
381
+ ``response``. The ``request`` is the webob request that caused the
382
+ transaction manager to become active. The ``response`` is the response
383
+ returned by the Pyramid application. This call signature is incompatible
384
+ with older versions. The call signature of a ``pyramid_tm`` 0.2 and older
385
+ commit veto accepted three arguments: ``environ``, ``status``, and
386
+ ``headers``. If you're using a custom ``commit_veto`` function, you'll
387
+ need to either convert your existing function to use the new calling
388
+ convention or use a wrapper to make it compatible with the new calling
389
+ convention. Here's a simple wrapper function
390
+ (``bwcompat_commit_veto_wrapper``) that will allow you to use your existing
391
+ custom commit veto function::
392
+
393
+ def bwcompat_commit_veto_wrapper(request, response):
394
+ return my_custom_commit_veto(request.environ, response.status,
395
+ response.headerlist)
396
+
397
+ Deprecations
398
+ ~~~~~~~~~~~~
399
+
400
+ - The ``pyramid_tm.commit_veto`` configuration setting is now canonically
401
+ spelled as ``tm.commit_veto``. The older spelling will continue to work,
402
+ but may raise a deprecation error when used.
403
+
404
+ 0.2 (2011-07-18)
405
+ ^^^^^^^^^^^^^^^^
406
+
407
+ - A new header ``X-Tm`` is now honored by the ``default_commit_veto`` commit
408
+ veto hook. If this header exists in the headerlist, its value must be a
409
+ string. If its value is ``commit``, the transaction will be committed
410
+ regardless of the status code or the value of ``X-Tm-Abort``. If the value
411
+ of the ``X-Tm`` header is ``abort`` (or any other string value except
412
+ ``commit``), the transaction will be aborted, regardless of the status code
413
+ or the value of ``X-Tm-Abort``.
414
+
415
+ 0.1 (2011-02-23)
416
+ ^^^^^^^^^^^^^^^^
417
+
418
+ - Initial release, based on repoze.tm2
419
+
@@ -0,0 +1,6 @@
1
+ pyramid_tm/__init__.py,sha256=OWV5QWZj4aRM7CMkbqXEAhjZJwARVqW-ewCaOh_8kqQ,10890
2
+ pyramid_tm-2.6.dist-info/LICENSE.txt,sha256=IBp9YkQVlUu4i1dgsbFKyAKQJ7dQ51QCGtX5A8SKde0,1719
3
+ pyramid_tm-2.6.dist-info/METADATA,sha256=7xJbT9xsm2r7WVng0JlIuEF-igzOMj_t_UeAUuq2y6c,15251
4
+ pyramid_tm-2.6.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
5
+ pyramid_tm-2.6.dist-info/top_level.txt,sha256=lOeSLNguPqy--9BzbJUpnjdvy_INIgp24cbie7ZIvWE,11
6
+ pyramid_tm-2.6.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.5.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ pyramid_tm