[mod_python] Returning a Apache return code

Nick nick at dd.revealed.net
Tue Nov 30 14:48:18 EST 2004


Yeah, that's a good case in point for the "almost always" :)  My main point 
is that often I see people using a 301 where a 307 is probably more appropriate.

Nick

Jorey Bump wrote:
> Nick wrote:
> 
>> Note that you should almost always use 307 (moved temporarily) for a 
>> web application, because 301 tells the client to always go to the new 
>> location when the URL is requested without even asking for the 
>> original page.  I.e., the page has moved permanently, don't look here 
>> anymore.
> 
> 
> It depends on your needs. I'm using HTTP_SEE_OTHER in my application to 
> sometimes redirect POST requests to an authentication page if the login 
> has expired. This tells the agent to request the new resource with GET, 
> preventing it from POSTing form data to the authentication page, which 
> is not under my control (or even in my site).
> 
>> Jorey Bump wrote:
>>
>>> Golawala, Moiz M (GE Infrastructure) wrote:
>>>
>>>> I have am newbie and I seems to be having a problem return a
>>>> different apache return code. In my httpd.conf file I am using
>>>> PythonHandler mod_python.publisher.
>>>>
>>>> In my index.py file.
>>>>
>>>> index(req): req.header_out['Location'] = "http://someurl:8080/ 
>>>
>>>
>>>
>>>  > return apache.HTTP_PERMANENTLY_MOVED
>>>
>>> Try this:
>>>
>>> from mod_python import apache
>>>
>>> index(req)
>>>     status = apache.HTTP_MOVED_PERMANENTLY
>>>     req.headers_out['Location'] = url
>>>     req.status = status
>>>     raise apache.SERVER_RETURN, status
>>>
>>> More info:
>>>
>>>  http://www.modpython.org/live/current/doc-html/pyapi-handler.html
> 
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list