[mod_python] Can't parse code

Graham Dumpleton grahamd at dscpl.com.au
Sun Mar 6 18:06:57 EST 2005


Do you see any messages of the form:

[Fri Sep 24 15:14:01 2004] [notice] mod_python: Creating 32 session mutexes based on 150 max processes and 0 max threads. 
[Fri Sep 24 15:14:01 2004] [notice] Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 configured -- resuming normal operations 

in the Apache error_log file where mod_python is mentioned. This should
be output when mod_python module is loaded by Apache, although the
exact details of version, number of process and threads will be different.

For your particular Apache installation, are modules definitely installed in
a "libexec" subdirectory? Verify where the mod_python.so is installed and
ensure config file is the same. Try using an absolute path to the location
of the mod_python.so rather than a relative path.

If there is some sort of problem with mod_python.so not finding required
libraries, would expect some other error message to be logged, so see if
there are any strange error messages at all in the error_log file.

Graham

=?ISO-8859-1?Q?M=E1rio_Gamito?= wrote ..
> Hi Graham,
> 
> Thank you very much for your help, but the proble persists :(
> 
> Apache still refuses to start with "PythonHandler mptest" in httpd.conf
> and without that the ouput to the browser is still the python code.
> 
> Any idea ?
> 
> Warm Regards,
> Mário Gamito
> 
> 
> Graham Dumpleton wrote:
> > You used the wrong documentation. You have installed 2.7.X but followed
> > instructions for 3.1.X for setting up test.
> > 
> > Change config to:
> > 
> > <Directory /var/www/html>
> >         AddHandler python-program .py
> >         PythonHandler mptest
> >         PythonDebug On
> > </Directory>"
> > 
> > Ie. change "mod_python" to "python-program".
> > 
> > Also recommended you change mptest.py code to:
> > 
> > from mod_python import apache
> > 
> > def handler(req):
> >         req.content_type = "text/plain"
> >         req.send_http_headers()
> >         req.write("Hello World!")
> >         return apache.OK
> > 
> > Ie., exlicitly set content type to "text/plain", otherwise you are at
> > mercy of server/browser config as to what type it is sent as, with browsers
> > sometimes asking you to save file rather than view it.
> > 
> > On 07/03/2005, at 7:04 AM, Mário Gamito wrote:
> > 
> >> Hi,
> >>
> >> I've installed mod_python in Apache, *carefully* following the 
> >> instructions in the site:
> >>
> >> "$ ./configure --with-apxs=/usr/local/apache/bin/apxs
> >> make
> >> make install"
> >>
> >> After that, i've configured (and restarted) Apache:
> >> "LoadModule python_module libexec/mod_python.so
> >>
> >> (...)
> >>
> >> <Directory /var/www/html>
> >>         AddHandler mod_python .py
> >>         PythonHandler mptest
> >>         PythonDebug On
> >> </Directory>"
> >>
> >> wrote the example in the tutorial:
> >> "from mod_python import apache
> >>
> >>     def handler(req):
> >>         req.write("Hello World!")
> >>         return apache.OK"
> >>
> >> and put it in /var/www/html in a file named mptest.py
> >>
> >> -- 
> >>
> >> Now, the problems :(
> >>
> >> Apache won't start if i have the lines:
> >> "PythonHandler mptest
> >> PythonDebug On"
> >>
> >> It says:
> >> "Invalid Command PythonHandler, perhaps mis-spelled or defined by a
> >> module not included in the server configuration"
> >> "Invalid Command PythonDebug, perhaps mis-spelled or defined by a 
> >> module not included in the server configuration".
> >>
> >> If i comment those lines, Apache starts but mod_python doesn't parse
> >> the code, it just displays it in the browser :(
> >>
> >> If i use a .htaccess file in /var/www/html, same thing happens.
> >>
> >> I've read the FAQ, googled for the problem, but did not found any 
> >> suggestion that solved this issue.
> >>
> >> I'm using Apache 1.3.33, mod_python 2.7.11 and Python 2.3.4
> >>
> >> I'm stuck on this :(
> >>
> >> Any help would be apreciated.
> >>
> >> Warm Regards,
> >> Mário Gamito
> >> _______________________________________________
> >> 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