-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 05/16/2011 02:27 AM, 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() > > 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') > > 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. > > Here's the branch: > > https://github.com/Pylons/pyramid/tree/httpexception-utils > > Here's the commit which added the feature: > > https://github.com/Pylons/pyramid/commit/1ffb8e3cc21603b29ccd78152f82cca7f61a09b1 > > It'd be nice to get some feedback from existing Pylons users to see if > the implementations of these features are "good enough"; it'd also be > nice to hear dissenting opinions with reasons for dissent if folks > believe this feature should not be added to Pyramid.
+1 to the 'abort()' and 'redirect()' APIs. - -1 to added non-local majyk in the guts of the publisher. I think the use case is better served by adding an exception-mapping decorator to the funcitons which might raise. Something like:: from webob.exc import HTTPException def returnRaised(wrapped): def _wrapper(*argv, **kw): try: return wrapped(*argv, **kw) except HTTPException, e: return e return _wrapper View code would look like:: @returnRaised def aview(request): abort(401) Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3RZbQACgkQ+gerLs4ltQ4TVgCfY6peYYiFAK3c+Gk/wIH6gynh g0IAoJjORRn9PCgF5gH0U2Q93ZjBtczr =LecC -----END PGP SIGNATURE----- -- 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.