[mod_python] Running more than one Python script

Ian Clelland ian at veryfresh.com
Sun Sep 1 03:00:23 EST 2002


On Sun, Sep 01, 2002 at 12:40:30AM -0400, Leader730 wrote:
> Hello, I am new to all this and I'm having a problem, I configured 
> mod_python on alright I guess but the only file that will run is the 
> the name specidied after PythonHandler in the apache httpd.conf file
> 
> <Directory "C:/Program Files/Apache Group/Apache/htdocs/server">
>    AddHandler python-program .py
>    PythonHandler test
> </Directory>

Yes, it looks like you have Apache configured correctly to run 
mod_python on all URLs which end in '.py' in that directory.
 
> so in this case only the file test.py would run, anything else would 
> return the same thing as test.py, I followed the tutorial and it says 
> that every file should run but it doesn't work for me, I have it 
> setup exactly like it says so If anyone knows how to fix this please 
> tell me (I'm running it on Windows btw).

The tutorial _does not_ say that every python file will be run by the 
server. The last paragraph of the tutorial (Section 3.2 of the manual) 
explains that Apache won't even look at the name of the file. Because 
of the way that Apache works, *EVERY* URL which ends in ".py" will 
cause mod_python to run the "test" module, in this case. This is the 
correct behaviour; Apache only allows you to set up one python handler 
per <Directory> tag.

If what you are looking for is a way to run various python files that 
you have placed in your web server directories, then you need to use a 
dispatcher handler, like Publisher. The Publisher handler looks at all 
of the requests which come in to the server, and passes them off to 
your python files, based on their filenames. Check out section 3.4 of 
the manual for a quick introduction to it.

Ian
<ian at veryfresh.com> 



More information about the Mod_python mailing list