mod_python problem

Discussion in 'Python' started by Gandalf, May 6, 2004.

  1. Gandalf

    Gandalf Guest

    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
     
    Gandalf, May 6, 2004
    #1
    1. Advertising

  2. Gandalf

    Peter Maas Guest

    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
    -------------------------------------------------------------------
     
    Peter Maas, May 7, 2004
    #2
    1. Advertising

  3. Gandalf

    poiboy Guest

    > 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
     
    poiboy, May 7, 2004
    #3
  4. Gandalf

    Gandalf Guest


    >>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, path)

    ImportError: No module named index
     
    Gandalf, May 7, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Medland

    Mod_python xml parsing problem

    Mike Medland, Jul 1, 2003, in forum: Python
    Replies:
    0
    Views:
    387
    Mike Medland
    Jul 1, 2003
  2. Doug Farrell

    Problem with mod_python and 4Suite

    Doug Farrell, Aug 8, 2003, in forum: Python
    Replies:
    2
    Views:
    348
    Doug Farrell
    Aug 12, 2003
  3. ws Wang
    Replies:
    2
    Views:
    492
    ws Wang
    Nov 30, 2004
  4. Manuel Pellecer

    mod_python config problem

    Manuel Pellecer, Jun 3, 2005, in forum: Python
    Replies:
    1
    Views:
    349
    Luis M. Gonzalez
    Jun 3, 2005
  5. blbmdsmith
    Replies:
    1
    Views:
    654
    Graham Dumpleton
    Dec 14, 2006
Loading...

Share This Page