mod_python problem

G

Gandalf

Hi All!

Here is my server signature:

Apache/2.0.48 (Unix) PHP/4.3.4 mod_python/3.0.3 Python/2.3.3
mod_ssl/2.0.48 OpenSSL/0.9.7c Server at arwen.msnet Port 80

This is what I have in httpd.conf:

LoadModule python_module libexec/apache2/mod_python.so
AddHandler mod_python .py
AddType applcation/x-http-python .py

<Directory />
PythonHandler mod_python.publisher
PythonDebug On
</Directory>

This is what I have in index.py (BTW it was taken from the mod_python
tutorial,
http://www.modpython.org/live/current/doc-html/tut-what-it-do.html ):

from mod_python import apache

def handler(req):
req.content_type = "text/plain"
req.write("Hello World!")
return apache.OK

Finally, the server starts OK, and when I try to GET this URL:

http://arwen.msnet/index.py?handler

then I get a plain/text file containing my Python code. It seems that
the handler does not work.
I tried to use this too:

PythonHandler index

but it did not work either. What did I wrong?

Thanks in advance,

G
 
P

Peter Maas

Gandalf said:
Apache/2.0.48 (Unix) PHP/4.3.4 mod_python/3.0.3 Python/2.3.3
mod_ssl/2.0.48 OpenSSL/0.9.7c Server at arwen.msnet Port 80

This is what I have in httpd.conf:

LoadModule python_module libexec/apache2/mod_python.so
AddHandler mod_python .py
AddType applcation/x-http-python .py

<Directory />
PythonHandler mod_python.publisher
PythonDebug On
</Directory>

I think your handler and your script don't match.
This is my working conf:

LoadModule python_module modules/mod_python.so
....
# This directive shouldn't be important (only for psp)
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks MultiViews +ExecCGI
AddHandler cgi-script cgi py
AddHandler mod_python .psp
PythonHandler mod_python.psp
PythonDebug On
</Directory>

# This directive enables Python scripts in a subdirectory
<Directory /usr/local/apache2/htdocs/test>
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
</Directory>

mptest.py:

from mod_python import apache

def handler(req):
req.write("Hello World!")
return apache.OK

Mit freundlichen Gruessen,

Peter Maas
 
P

poiboy

Here is my server signature:
Apache/2.0.48 (Unix) PHP/4.3.4 mod_python/3.0.3 Python/2.3.3
mod_ssl/2.0.48 OpenSSL/0.9.7c Server at arwen.msnet Port 80

This is what I have in httpd.conf:

LoadModule python_module libexec/apache2/mod_python.so
AddHandler mod_python .py
AddType applcation/x-http-python .py

Try:

AddHandler python-program .py

The "AddHandler mod_python .py" version is intended to work with mod_python
3.1.3 and higher. Check out http://www.modpython.org/FAQ/faqw.py?req=all.

For sympathy's sake, I've been using the manual released with 3.1.0a which also
uses "AddHandler mod_python" and doesn't mention python-program at all.

Aloha,
the poiboy
 
G

Gandalf

Try:

AddHandler python-program .py

The "AddHandler mod_python .py" version is intended to work with mod_python
3.1.3 and higher. Check out http://www.modpython.org/FAQ/faqw.py?req=all.

For sympathy's sake, I've been using the manual released with 3.1.0a which also
uses "AddHandler mod_python" and doesn't mention python-program at all.

Aloha,
the poiboy

God bless you!

I have been trying for days without success. Now I got this error below,
and I'm very happy with that. No question, I can handle from here. :)

Many thanks,

G

http://arwen.msnet/index.py:

Mod_python error: "PythonHandler index"

Traceback (most recent call last):

File "/usr/local/lib/python2.3/site-packages/mod_python/apache.py", line 320, in HandlerDispatch
module = import_module(module_name, config)

File "/usr/local/lib/python2.3/site-packages/mod_python/apache.py", line 496, in import_module
f, p, d = imp.find_module(parts, path)

ImportError: No module named index
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top