[mod_python] Custom Login with redirection back to referer

Graham Dumpleton grahamd at dscpl.com.au
Sun May 21 02:01:22 EDT 2006


On 21/05/2006, at 3:23 PM, Deron Meranda wrote:

> On 5/20/06, Jim Gallacher <jpg at jgassociates.ca> wrote:
>> But I suspect if browser is too old to understand a 307 redirect,  
>> most
>> web pages that user visits are almost completely unreadable  
>> anyway. :)
>
> I still remember coding up web pages for the old Mosaic
> browser, so by this point what's old, new, or stone-age
> is pretty much a blur ;)
>
>> Not completely on topic, but since we are talking about 30x  
>> redirects, I
>> thought I'd mention that I've modified util.redirect to support  
>> any of
>> the 30x codes. It's a pretty simple change, where util.redirect  
>> becomes
>>
>> def redirect(req, location, permanent=0, status=None, text=None)
>>
>> If status is not None it overrides the permanent parameter. I want  
>> this
>> so I use util.redirect with a 303 HTTP_SEE_OTHER response after  
>> creating
>> a resource with a POST. (for the POST-REDIRECT-GET pattern used in
>> RESTful applications).
>
> It's nice to get support for more the the response codes.  I think
> it's interesting to see how designing RESTful makes one think
> a lot more about the why and not just how of the HTTP protocol
> details.
>
> As far as the redirect() function.  The only thing that bothers
> me a bit is having two mutually-exclusive parameters.  But I'm
> not sure how you'd fix that will maintaining backwards compatibility.
>
> But I have to admit I often do things the "hard way" out of
> habit back from the days when I coded "nph-" style CGI scripts.
> I tend not to use the redirect() helper function, and instead
> do everyting at a lower level.  Some day I'll convert.

Personally I am probably -1 on overloading util.redirect() to do  
this. That function
isn't too complicated, but probably should be kept just for the  
simple cases. If
someone knows enough to use other cases, they are probably knowledgeable
enough to know how to do it properly themselves at the lower level.

Graham


More information about the Mod_python mailing list