-
Notifications
You must be signed in to change notification settings - Fork 887
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
Response callbacks not always invoked after exception view #3468
Comments
At least in
Part of the docs, since the exception is not a valid response object that is returned. I am not sure it is a good idea for I would question why your exception is falling through to the execution policy of |
The same statements stand for the default execution policy: https://github.com/Pylons/pyramid/blob/master/src/pyramid/router.py#L274 |
I think in hindsight it was probably a mistake to have the execution policy call [1] For example, pyramid_tm adds a |
I should point out that pyramid_retry has this behavior builtin as well because it operates outside of the request lifecycle but does call I'd be open, at the very least, to changing Pyramid's default execution policy back to not calling |
I have pushed changes for this to #3496 and also to pyramid_retry. I'm hesitant to backport this as it's a sort of bw-incompat change but you could probably talk me into it. It'll at least be in 2.0. In the meantime you can fix it in your apps by defining your own excecution policy. def my_execution_policy(environ, router):
with router.request_context(environ) as request:
return router.invoke_request(request)
config.set_execution_policy(my_execution_policy) |
In Using Hooks it is stated that "Response callbacks are, however, invoked when a exception view is rendered successfully." While this is true when the exception view is invoked by the excview_tween, it may also be invoked by the execution policy in which case the response callbacks are not invoked.
When ab exception is raised under excview_tween the following are executed in order:
When an exception is raised over excview_tween it is:
In my case I had an exception view registered that called
request.session.changed()
to refresh the session cookie. BaseCookieSessionFactory.changed sets the cookie in a response callback so this no longer works.I'm not sure if this a documentation or a behavioral issue.
The text was updated successfully, but these errors were encountered: