[mod_python] Fixup hander not always being called

Michael C. Neel neel at mediapulse.com
Wed Mar 12 10:57:25 EST 2003


I have some mod perl code I'm trying to move over to modpython.  The
perl code adds a cookie header to all requests using the fixup phase,
and then logs some info in the logging phase.  When I setup python to do
the same, the fixup handler is not always called.  It looks like it is
related to cgi scripts, as when I hit a cgi page in the web browser, my
fixup handler is not called - but it will call the perl version.

My conf has:

    <Location />
        #SetHandler python-program
        PythonLogHandler qlog
        PythonFixupHandler qlog
        PythonDebug On
    </Location>

I've commented out the SetHandler because that would break cgi scripts
(causing the text of the script to be sent to the browser, instead of
executing it).  This is the same with mod_perl, you can't use the
SetHandler.

qlog.py (simplified):

from mod_python import apache

def fixuphandler(req):

    apache.log_error("----------- New Hit -----------")
    apache.log_error("CT: " + str(req.content_type))

def loghandler(req):

    apache.log_error("----------- Log Hit -----------")


Any insights?  I'd like to do the new version of this code in python,
and not perl, but I gotta get this cgi snafu solved.

Thanks,
Mike




More information about the Mod_python mailing list