On Jan 9, 2008 1:16 PM, Kevin Baker <[EMAIL PROTECTED]> wrote: > > > I am on Pylons 0.9.6.1. I see that there have been changes for the > usage of the response object in the controller. > > I am new to Pylons and thought I'd start with Authkit implementation > to my current db of users. In the Cookbook example I was following it > uses Response directly and throws a "401" status. > > How would I do this with the current implementation? > > Current Code: > > <code python> > response.status = "401 Not authenticated" > return 'You are not Authenticated' > </code> > > > Tutorial Code: > > <code python> > response = Response('You are not authenticated') > response.status = "401 Not authenticated" > return res > </code> > > > I'm considering custom authentication, but want to be sure I > understand the response object better before moving on.
Your current code is correct. The tutorial is following the older Pylons 0.9.5 convention, and should be updated. However, either way will work. By the way, the easiest way to do this is to call "abort(401)". This raises an HTTPNotAuthorized exception and modifies the response for you. I haven't looked at AuthKit closely enough to be 100% sure it's compatible with what they're doing, but it's emerging as the "standard" way to signal HTTP errors. You can include a custom message as the second argument if you wish. -- 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 pylons-discuss@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---