[mod_python] inithandler never called?

Jerry Seutter jseutter at gmail.com
Thu Sep 9 12:42:57 EDT 2004


Hi,

I'm trying to use mod_python's PythonInitHandler hook and it never
seems to be called.  I'm pretty sure I'm doing something stupid, but I
can't figure out what it is.

Here is the relevant section from my httpd.conf:

=======================================
Alias "/mod_python" "/var/www/mod_python"

<Directory "/var/www/mod_python">
    AddHandler python-program .py
    PythonInitHandler mod_python_test
    PythonAccessHandler mod_python_test
    PythonAuthenHandler mod_python_test
    PythonFixupHandler mod_python_test
    PythonHandler mod_python_test
    PythonPath "sys.path+['/var/www/mod_python','/usr/lib/python2.2/site-packages/mod_python']"
</Directory>
=======================================

Here is the mod_python_test.py:

=======================================
import apache
import sys

myvar = "not initted"

def inithandler(req):
    global myvar
    sys.stderr.write('inithandler called\n')
    sys.stderr.flush()
    myvar = "I have been initted!!!"
    return apache.OK
    
def accesshandler(req):
    return apache.OK

def authenhandler(req):
    return apache.OK

def handler(req):
    req.content_type = "text/html"
    req.write('<html><body>')
    req.write('%s<br>' %(myvar))
    req.write('</body></html>')

    return apache.OK
=======================================

and here is what I get when I hit
http://localhost/mod_python/mod_python_test.py:

=======================================
<html><body>not initted<br></body></html>
=======================================

I'm using:
mod_python-3.0.3-2.ent
python-2.2.3-26
httpd-2.0.46-25.ent
(on redhat as 3)

If anyone knows what I'm doing wrong and feels like telling me, thanks!

Jerry Seutter


More information about the Mod_python mailing list