On Fri, Oct 17, 2008 at 10:40 AM, Adam Peacock <[EMAIL PROTECTED]> wrote: > > Due to the way my user authentication works, I'm rolling my own. It's > all work well, and I have it working with decorators, except for a > funny issue - when I raise a redirect_to from my decorator, Pylons > displays the error in debug mode, rather than actually redirecting. > > In the debug I get a stack trace with "HTTPFound: 302 Found content- > type: text/html; charset=UTF-8 Content-Length: 0 location: /login/ " > > Anyone have any idea? Or is there a better way to do this?
redirect_to() and abort() raise an HTTP exception, which is caught somewhere in Pylons or Paste or the error handler to convert it to an error page. If you call them above this level, that will not happen and the error middleware will treat it as an unknown exception. So you'll probably have to set the HTTP status manually. However, why this is happening in a decorator doesn't make sense, because you'd think an action decorator would behave the same as if the code were in the action itself. Although I get confused about decorators anyway. It seems like in the successful case, you should call the wrapped function and return its result, rather than returning nothing. But perhaps that was just left out of the example. -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
