You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This has been bugging me for a while. According to the docs, there were two ways you can call HTTPFound under Pyramid:
raise HTTPFound( url )
return HTTPFound( url )
But... these two methods behave rather differently.
With the latest 1.3/1.4 commits, there seems to be some activity around the request/response/event framework and exceptions , so I wanted to bring this up.
I'm illustrating this using cookie info ( which is what I cared about ), but this holds true for all headers because Pyramid throws out the response information when a raise redirect happens.
If you raise the HTTPFound, the headers are discarded along with the request.response
If you return the HTTPFound, the response, and headers, remain on the request
Yes, raise behaves differently than return. This is unlikely to change. A docs pull request that made the difference in behavior clearer would be nice.
This has been bugging me for a while. According to the docs, there were two ways you can call HTTPFound under Pyramid:
But... these two methods behave rather differently.
With the latest 1.3/1.4 commits, there seems to be some activity around the request/response/event framework and exceptions , so I wanted to bring this up.
I'm illustrating this using cookie info ( which is what I cared about ), but this holds true for all headers because Pyramid throws out the response information when a
raise
redirect happens.raise
the HTTPFound, the headers are discarded along with the request.responsereturn
the HTTPFound, the response, and headers, remain on the requestI created this standalone gist to illustrate :
gist = https://gist.github.com/3739936
url_a = /raise
url_b = /return
If you run the gist, you can see from python's object ids that on a
raise
, pyramid replaces the entire request.response object.that kind of sucks. the old response data should still be available.
The text was updated successfully, but these errors were encountered: