[mod_python] inithandler never called?

Jerry Seutter jseutter at gmail.com
Thu Sep 9 13:56:16 EDT 2004


Ahh, thanks for the heads-up.  This won't work for the problem I'm trying
to solve.

Can a link to this information be put in section 5.1.5 of the documentation?  I 
went back and looked through the documentation some more and I can't find
where this note came from.  Searching on the modpython.org didn't turn up
this text either.

Thanks,

Jerry Seutter


On Thu, 9 Sep 2004 14:03:28 -0400, Ross M Karchner
<rosskarchner at gmail.com> wrote:
> the 3.1 documentation says that InitHandler can't be used in a <Directory>
> 
> """Note: When this phase of the request is processed, the URI has not
> yet been translated into a path name, therefore this directive could
> never be executed by Apache if it could specified within <Directory>,
> <Location>, <File>
> directives or in an '.htaccess' file. The only place this directive is
> allowed is the main configuration file, and the
> code for it will execute in the main interpreter. And because this
> phase happens before any identification of the type
> of content being requested is done (i.e. is this a python program or a
> gif?), the python routine specified with this
> handler will be called for ALL requests on this server"""
> 
> 
> 
> 
> On Thu, 9 Sep 2004 11:42:57 -0600, Jerry Seutter <jseutter at gmail.com> wrote:
> > 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
> > _______________________________________________
> > 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