On Tue, 2010-12-28 at 16:17 -0800, Mike Orr wrote:
> On Tue, Dec 28, 2010 at 1:43 PM, Chris McDonough <[email protected]> wrote:
> > On Tue, 2010-12-28 at 22:35 +0100, Eric Lemoine wrote:
> >> Hello
> >>
> >> Does Pyramid provide a helper for issuing redirects? I've found
> >> nothing in the docs about that. Maybe pyramid_routehelper will provide
> >> that?
> >
> > Hi Eric,
> >
> > http://docs.pylonshq.com/pyramid/dev/narr/views.html#using-a-view-callable-to-do-an-http-redirect
>
> "Although exception types from the pyramid.httpexceptions module are
> in fact bona fide Python Exception types, the Pyramid view machinery
> expects them to be returned by a view callable rather than raised."
>
> Is raising HTTP exceptions still supported? Sometimes it provides
> better documentation or lets you jump out of a utility method without
> having to put extra code in surrounding loops in the caller.
To make "raising exceptions possible" you can add the following code:
def error_view(context, request):
return context
And in your configuration:
from webob.exc import HTTPException
config.add_view(error_view, context=HTTPException)
This will only work in Python 2.5+ (due to WebOb implementation
constraints).
See also
http://docs.pylonshq.com/pyramid/dev/narr/views.html#exception-views
I'll add this to the docs.. somewhere.
- C
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.