[mod_python] what's happen?

Miguel Marques miguel at yorku.ca
Mon Feb 26 15:01:24 EST 2001


On Tue, 27 Feb 2001 03:25:48 +0800 (CST), gege at china.com wrote:
> under redhat 6.2 python 2.1a2 mod_python 2.7.2 apache 1.3.12
> 
> lynx http://localhost/python/mptest.py
> 
> it appears Hello World!
> 
> but when I type lynx http://localhost/python/test.py or some other filename.py
> 
> it also appears Hello World!
> 
> I don't understand...

AddHandler python-program .py
specifies .py files are to be handled by the handler python-program.

The handler for files of type python-program in that directory is
whatever you specified as the PythonHandler in your apache
configuration file.

So any filename ending in .py gets handled by running mptest.py (I'm
guessing that's what you specified).
If you wanted to do something based on the filename you could 
look at req.uri in mptest.py.

If for instance you use 
SetHandler python-program
instead of
AddHandler python-program .py
then any reference to a file in that directory runs mptest.py
regardless of extension.

Hope this helps.

							Miguel

C. Miguel Marques, York University, Computing & Network Services
e-mail: miguel at yorku.ca, voice: (416)736-2100x22684, fax: (416)736-5830



More information about the Mod_python mailing list