[mod_python] mod_python.util Supplement function: refresh

Sean Jamieson sean at barriescene.com
Wed Jan 25 12:31:28 EST 2006


Graham Dumpleton wrote:

>Sean Jamieson wrote ..
>  
>
>>I've written a supplemental function for the mod_python.util module, 
>>similar to mod_python.util.redirect, this is a helper function that sets
>>the Refresh header.
>>
>>Personally I use Refresh atleast as much Location (redirct), if not more.
>>
>>So here it is, in all it's simplicity:
>>
>>def refresh(req, time, location=None):
>>    """refresh( req, seconds, location=None ) -> None
>>
>>    A convenience function to provide refresh/redirection via the HTTP
>>Refresh header
>>    """
>>    if req.sent_bodyct:
>>        raise IOError, "Cannot send refresh header after headers have 
>>already been sent."
>>    req.err_headers_out["Refresh"] = str(seconds) # seconds is usually
>>given as an integer
>>    if location:
>>        req.err_headers_out["Refresh"] += ';url=' + location
>>    
>>
>
>If you want to ensure this gets considered at some point, log it as a
>new feature/wish at:
>
>  http://issues.apache.org/jira/browse/MODPYTHON
>
>Requests like this only posted to the mailing list inevitably get lost
>over time.
>
>Graham
>  
>
Thank you, Graham

Sean


More information about the Mod_python mailing list