[mod_python] mod_python.util Supplement function: refresh

Sean Jamieson sean at barriescene.com
Tue Jan 24 16:56:11 EST 2006

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

More information about the Mod_python mailing list