[mod_python] installation config to allow different programs

Steven Hanley sjh at wibble.net
Wed Sep 19 17:13:33 EST 2001


All

I am not on the list so could any replies also be cc'd to me.

Reading the documentation it suggests doing something like 

<IfModule mod_python.c>
  Alias /python/ /some/where/
  <Location /python>
    AddHandler python-program .py
    PythonHandler someprog     
  </Location>
</IfModule>  

which will cause the handler method in someprog to be run whenever any
random.py program is accessed at http://servername/python/random.py.

I am wondering why there is no handler distributed with mod python to simply
allow something more like.

<IfModule mod_python.c>
  Alias /python/ /some/where/
  <Location /python>
    SetHandler python-program
    PythonHandler mod_python.run      
  </Location>
</IfModule>  

Where any file in /python can be accessed and run with mod_python. I know
there is the publisher module but that is not what I am thinking of.

More if we have a 

program named "first" which contains python code such as 

from mod_python import apache

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

and another program named "second" with the code

from mod_python import apache

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

and an access to 

http://servername/python/first gives the Hello World program
an access to 
http://servername/python/second gives the Goodby World program

Also notice the programs dont have any .py extension.

So I was unable to work out a way to configure mod_python to handle this sort
of case. Can someone please help.

It seems in the documentation we jump straight from explicit reference to a
single program.py to using something like publisher.

I saw someone say they had tried to do this and it wasnt working on this
mailing list

http://www.modpython.org/pipermail/mod_python/2001-August/001606.html

but he then came back and said it was working two posts later without any
explanation of how.

I see the same behavior, it just sends the source code of the pythong program
back to the browser.

       See You
           Steve

-- 
sjh at wibble.net http://wibble.net/~sjh
Look Up In The Sky
    Is it a bird?   No
        Is it a plane    No
            Is it a small blue banana?
Yes



More information about the Mod_python mailing list