[mod_python] inithandler never called?

Scott Sanders sanders at apache.org
Mon Sep 13 08:42:06 EDT 2004


I found that PythonInitHandler does NOT seem to be an alias to  
PythonHeaderParserHandler, since one works for me and the other doesn't  
:)

PythonInitHandler has never worked in any of my setups.

Scott

On Sep 9, 2004, at 12:09 PM, Jerry Seutter wrote:

> Actually, are you sure this information is correct?  I found the text
> as part of the
> PythonPostReadRequestHandler documentation, not PythonInitHandler.  In
> fact, the PythonInitHandler says that it is valid in directory
> contexts.
>
> At any rate, since PythonInitHandler is an alias to
> PythonHeaderParserHandler when in a directory context, I can use that
> instead.  It seems to be working...
>
> Jerry
>
> 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
>>>
>>>
>>
> _______________________________________________
> 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