Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > mod_python problem

Reply
Thread Tools

mod_python problem

 
 
Gandalf
Guest
Posts: n/a
 
      05-06-2004
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/curren...hat-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




 
Reply With Quote
 
 
 
 
Peter Maas
Guest
Posts: n/a
 
      05-07-2004
Gandalf wrote:
> 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

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail http://www.velocityreviews.com/forums/(E-Mail Removed)
-------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
poiboy
Guest
Posts: n/a
 
      05-07-2004
> 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
 
Reply With Quote
 
Gandalf
Guest
Posts: n/a
 
      05-07-2004

>>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
>


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[i], path)

ImportError: No module named index



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mod_python.so is garbled mod_python.so is garbled blbmdsmith Python 1 12-14-2006 12:15 AM
mod_python config problem Manuel Pellecer Python 1 06-03-2005 10:10 PM
MySQLdb problem with mod_python, please help ws Wang Python 2 11-30-2004 08:40 PM
Problem with mod_python and 4Suite Doug Farrell Python 2 08-12-2003 12:21 PM
Mod_python xml parsing problem Mike Medland Python 0 07-01-2003 08:08 AM



Advertisments