[mod_python] Can't parse code

Mário Gamito lists at tuxdoit.com
Sun Mar 6 17:25:46 EST 2005


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