-
Notifications
You must be signed in to change notification settings - Fork 888
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
add a router.request_context context manager #3086
Conversation
912c5ef
to
d3af568
Compare
I'm a little iffy on whether I should add this to the router interface or simply provide this as a new API for managing threadlocals. Currently pyramid provides
Arguably every single one of these could be replaced with a common API such as This is the only thing holding up the 1.9 release and I would really appreciate some input. |
I think adding a new The fact that each of those places where we currently push the There may be other areas where someone might want to push/pop the Just thinking about I am a 👎 on this current PR as it stands, it feels wrong. I've been thinking about this for the past couple of days and even-though it's a pain to have yet another API, I think it is a good idea to introduce it. |
I've decided not to go that route because I prefer Pyramid's API to force users to do the right thing when possible versus just adding an API they could use. I'm going to keep things about the same but with a couple changes:
def default_execution_policy(environ, router):
with router.request_context(environ) as request:
try:
return router.invoke_request(request)
except Exception:
return request.invoke_exception_view(reraise=True) |
the request context is to be used by execution policies to push/pop threadlocals and access the created request
d3af568
to
8226534
Compare
@bertjwregeer please review this again and let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
the context manager may be used by execution policies to push/pop threadlocals
if necessary