-
Notifications
You must be signed in to change notification settings - Fork 882
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
update render_to_response to prevent renderers from mutating request.response #1563
Conversation
In 72bf6bb I added the ability to specify a custom response object as an argument. So if you need to modify some params prior to the renderer touching the object then you can just create the object and pass it in.
This PR very slightly backward incompatible since it was apparently documented to mutate |
It was documented that if you mutated The one thing you could add to be backwards compatible to what was documented was to make a copy of the response object on |
What approach would you take? I'm still leaning toward my solution atm because I think it makes more sense. Compatibility has not yet dissuaded me. |
Honestly the original way was very unintuitive, I would go with your changes and call it good. I simply pointed out that the language used in the original docstring gave you some leeway to make a b/w compat fix. |
LGTM |
update render_to_response to prevent renderers from mutating request.response
These tests test for, among other things, the nits described in comments on Pylons#1563, namely: - ``Request.response`` should be restored even in the renderer raises an exception - If ``request.response`` is initially set to ``None``, it should be restored to ``None`` (rather than deleted). (Some of these tests currently fail.)
This fixes two bugs in the ``temporary_response`` context manager: - ``Request.response`` should be restored even in the renderer raises an exception - If ``request.response`` is initially set to ``None``, it should be restored to ``None`` (rather than deleted). References: Pylons#1563
These tests test for, among other things, the nits described in comments on Pylons#1563, namely: - ``Request.response`` should be restored even if the renderer raises an exception - If ``request.response`` is initially set to ``None``, it should be restored to ``None`` (rather than deleted). (Some of these tests currently fail.)
This fixes two bugs in the ``temporary_response`` context manager: - ``Request.response`` should be restored even if the renderer raises an exception - If ``request.response`` is initially set to ``None``, it should be restored to ``None`` (rather than deleted). References: Pylons#1563
These tests test for, among other things, the nits described in comments on #1563, namely: - ``Request.response`` should be restored even if the renderer raises an exception - If ``request.response`` is initially set to ``None``, it should be restored to ``None`` (rather than deleted). (Some of these tests currently fail.)
This fixes two bugs in the ``temporary_response`` context manager: - ``Request.response`` should be restored even if the renderer raises an exception - If ``request.response`` is initially set to ``None``, it should be restored to ``None`` (rather than deleted). References: #1563
fixes #1536
I think this should be fairly non-controversial. When using
render_to_response
you'd probably expect that to not have any side effects onrequest.response
which you may also end up using during the request. This patch just keeps them separate.