Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depend on pyramid_retry and move the tween over the excview #55

Merged
merged 6 commits into from
Mar 10, 2017

Conversation

mmerickel
Copy link
Member

This PR removes attempt / retry support. As such the tm is now simpler and focuses only on handling exceptions. The tm is also moved above the excview so that exception views are managed by the transaction manager.

I have hopes that we will eventually move the response callbacks to a tween as well and then we would move the tm over them as well, but that is not the case in this PR.

I had a version of this that depended on pyramid_retry but it turned out that I could keep pyramid_tm working on older versions of pyramid if I didn't, and since it's a totally separate project now it actually works without the retry support anyway if you don't want it. A warning is emitted now if pyramid_retry is not installed and tm.attempts is set.

This is a breaking change that would be released as pyramid_tm 2.0.

activate_hook = maybe_resolve(activate_hook)
annotate_user = asbool(settings.get('tm.annotate_user', True))

if 'tm.attempts' in settings: # pragma: no cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked pyramid_retry but does it support tm.attempts? Or should we link to documentation on how to configure pyramid_retry.

If someone is using tm.attempts and wants to stick to Pyramid <=1.7 they will have to use an older version of pyramid_tm. I am okay with that, just something we should document heavily.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shipped pyramid_retry 0.1 with support for tm.attempts but I changed my mind in 0.2 and now it only supports retry.attempts. This is so that tm.attempts is unused and I can properly warn people here to stop using it.


from .compat import reraise
from .compat import binary_type, text_type
from .compat import text_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if instead of carrying this compat around, we should just import it from pyramid.compat... but I have a feeling that is a larger change in the context of pyramid_*.

if request.tm._retryable(*exc_info[:-1]):
exc = exc_info[1]
if exc:
zope.interface.directlyProvides(exc, IRetryableError)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best use of zope.interface I have seen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed a version that uses z.i.alsoProvides thanks to @davisagli catching the issue. Super subtle!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants