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

inconsistent behavior of httpfound ( and other exceptions ) #691

Closed
jvanasco opened this issue Sep 17, 2012 · 2 comments
Closed

inconsistent behavior of httpfound ( and other exceptions ) #691

jvanasco opened this issue Sep 17, 2012 · 2 comments
Labels

Comments

@jvanasco
Copy link
Contributor

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

I 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.

@mcdonc
Copy link
Member

mcdonc commented Feb 10, 2013

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.

@mcdonc
Copy link
Member

mcdonc commented Aug 10, 2013

Closing.

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

No branches or pull requests

2 participants