[mod_python] Custom Login with redirection back to referer

Deron Meranda deron.meranda at gmail.com
Sun May 21 01:23:40 EDT 2006

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

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.

> The 304 HTTP_NOT_MODIFIED redirect looks interesting in particular,

Yes, it is.  It is one of those uncommon ones that I use a bit.  Other
ones I find myself using occasionally are:
  201 Created
  202 Accepted
  400 Bad request
  403 Forbidden
  405 Method not allowed
  503 Service unavailable

You might want to think about 413 (request entity too large) as
possibly something that really belongs in the inner workings
of mod_python's FieldStorage stuff.

Deron Meranda

More information about the Mod_python mailing list