[mod_python] Re: Mod_python Digest, Vol 31, Issue 32

Jorey Bump list at joreybump.com
Mon Oct 17 09:17:26 EDT 2005


Gavin wrote:

> I  plan to develop an HTTP API for my application. How to change HTTP 
> status code and HTTP reason message?

Please don't reply to the digest. Compose a new message when posting a 
new topic to the list. :)

Start here:

  http://www.modpython.org/live/current/doc-html/pyapi-handler.html
  http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

A function to redirect after authorization has expired might look like this:

from mod_python import apache

def redirect(req, newurl):
     """
     Redirect without sending form data to new URL.
     Sends HTTP Status Code 303.
     """
     status = apache.HTTP_SEE_OTHER
     req.headers_out['Location'] = newurl
     req.status = status
     raise apache.SERVER_RETURN, status





More information about the Mod_python mailing list