Apache 2.2.3 and mod_python 3.2.10

Discussion in 'Python' started by m.banaouas, Dec 19, 2006.

  1. m.banaouas

    m.banaouas Guest

    I installed Apache 2.2.3 and mod_python 3.2.10 on WinXP plateform
    I configured mod_python via httpd.conf:
    LoadModule python_module modules/mod_python.so

    but my script folder configuration doesn't work correctely:

    Alias /myfolder D:/myfolder

    <Directory "/myfolder">
    Order allow,deny
    Allow from all
    AddHandler mod_python .py
    PythonHandler mod_python.publisher
    PythonDebug On
    </Directory>

    for test, this is a sample script d:\myfolder\test.py
    # test.py
    #
    from mod_python import apache
    #
    def hello(name=None):
    if name:
    return 'Hello, %s!' % name.capitalize()
    else:
    return 'Hello there!'
    #
    def handler(req):
    req.content_type = 'text/plain'
    req.write("from handler test, Hello World!")
    return apache.OK

    when I access to the url http://localhost/monrep/test.py,
    I obtain source test.py listing but not the rendering of handler or
    hello method.

    with url http://localhost/theriaque/test.py/hello, I obtain :
    =>The requested URL /theriaque/test.py/hello was not found on this server.

    It seems like something is missing ... but what ?

    thanks for any help
     
    m.banaouas, Dec 19, 2006
    #1
    1. Advertising

  2. m.banaouas

    m.banaouas Guest

    sorry, I give here the right paths:

    I installed Apache 2.2.3 and mod_python 3.2.10 on WinXP plateform
    I configured mod_python via httpd.conf:
    LoadModule python_module modules/mod_python.so

    but my script folder configuration doesn't work correctely:

    Alias /myfolder D:/myfolder

    <Directory "/myfolder">
    Order allow,deny
    Allow from all
    AddHandler mod_python .py
    PythonHandler mod_python.publisher
    PythonDebug On
    </Directory>

    for test, this is a sample script d:\myfolder\test.py
    # test.py
    #
    from mod_python import apache
    #
    def hello(name=None):
    if name:
    return 'Hello, %s!' % name.capitalize()
    else:
    return 'Hello there!'
    #
    def handler(req):
    req.content_type = 'text/plain'
    req.write("from handler test, Hello World!")
    return apache.OK

    when I access to the url http://localhost/myfolder/test.py,
    I obtain source test.py listing but not the rendering of handler or
    hello method.

    with url http://localhost/myfolder/test.py/hello, I obtain :
    =>The requested URL /myfolder/test.py/hello was not found on this server.

    It seems like something is missing ... but what ?

    thanks for any help
     
    m.banaouas, Dec 19, 2006
    #2
    1. Advertising

  3. m.banaouas wrote:
    > sorry, I give here the right paths:
    >
    > I installed Apache 2.2.3 and mod_python 3.2.10 on WinXP plateform
    > I configured mod_python via httpd.conf:
    > LoadModule python_module modules/mod_python.so
    >
    > but my script folder configuration doesn't work correctely:
    >
    > Alias /myfolder D:/myfolder
    >
    > <Directory "/myfolder">
    > Order allow,deny
    > Allow from all
    > AddHandler mod_python .py
    > PythonHandler mod_python.publisher
    > PythonDebug On
    > </Directory>
    >
    > for test, this is a sample script d:\myfolder\test.py
    > # test.py
    > #
    > from mod_python import apache
    > #
    > def hello(name=None):
    > if name:
    > return 'Hello, %s!' % name.capitalize()
    > else:
    > return 'Hello there!'
    > #
    > def handler(req):
    > req.content_type = 'text/plain'
    > req.write("from handler test, Hello World!")
    > return apache.OK
    >
    > when I access to the url http://localhost/myfolder/test.py,
    > I obtain source test.py listing but not the rendering of handler or
    > hello method.
    >
    > with url http://localhost/myfolder/test.py/hello, I obtain :
    > =>The requested URL /myfolder/test.py/hello was not found on this server.
    >
    > It seems like something is missing ... but what ?
    >
    > thanks for any help


    Get it working for a normal handler first and don't use
    mod_python.publisher.

    For a set of instructions on how to get a simple handler working,
    including descriptions of common problems and how to debug it, see:


    http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking

    Once you have confirmed that your installation works, then consider
    looking at mod_python.publisher.

    I'd also suggest that you get yourself on the mod_python user mailing
    list and seek help there as the mod_python community there is much
    larger. Mailing list details are on the mod_python web site.

    BTW, don't you mean:

    <Directory "D:/myfolder">

    if that is what Alias uses?

    Also, don't mix normal handlers and mod_python.publisher functions in
    the same module, and don't use files called 'test.py' as there is a
    standard Python module by the same name and if things aren't set up
    right you can be picking up the wrong module.

    Graham
     
    Graham Dumpleton, Dec 19, 2006
    #3
    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. Markus Schaber

    Apache mod_python and Sessions

    Markus Schaber, Jul 4, 2003, in forum: Python
    Replies:
    7
    Views:
    879
    Irmen de Jong
    Jul 8, 2003
  2. John Dean
    Replies:
    6
    Views:
    471
    Dave Benjamin
    Sep 11, 2003
  3. andy
    Replies:
    3
    Views:
    423
    Michael Fuhr
    Oct 2, 2004
  4. blbmdsmith
    Replies:
    1
    Views:
    682
    Graham Dumpleton
    Dec 14, 2006
  5. NccWarp9
    Replies:
    1
    Views:
    445
    Graham Dumpleton
    Mar 31, 2008
Loading...

Share This Page