On 2011-5-16 08:27, Chris McDonough wrote:
I've created a branch named "httpexception-utils" on GitHub which
contains an implementation of "redirect" and "abort" for Pyramid that
act like their Pylons brethren.
In short, the abort feature is used like this:
from pryamid.httpexceptions import abort
def aview(request):
abort(401)
This will perform the same job as what used to be necessary as:
def aview(request):
return HTTPUnauthorized()
-1
I find "return HTTPUnauthorized()" to be immensely more readable then
"abort(401)", so for me that is a step backwards.
The redirect feature is used like this:
from pryamid.httpexceptions import redirect
def aview(request):
redirect('http://example.com')
This will perform the same job as what used to be necessary as:
def aview(request):
return HTTPFound(location='http://example.com')
-0
Readability of these is similar, so no objections for that reason. Here
I prefer returning a response for consistency: you also return responses
for Forbidden, NotFound and Unauthorized to it makes sense to use a
response here as well.
In addition, any "HTTP exception" (an exception imported from
pyramid.httpexceptions) can now be raised rather than returned. The
object raised will be used as a response.
+0
+1 if that is also supported for context factories.
Wichert.
--
Wichert Akkerman <wich...@wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
--
You received this message because you are subscribed to the Google Groups
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/pylons-devel?hl=en.