[mod_python] addhandler or sethandler

Graham Dumpleton grahamd at dscpl.com.au
Wed May 17 00:09:36 EDT 2006


> Graham Dumpleton wrote:
> > David Bear wrote ..
> >> However, the below htaccess file produces the expected result, it
> >> executes the python function, which is:
> >>
> >> from mod_python import apache
> >>
> >> def handler ( req ):
> >>   req.content_type = "text/plain"
> >>   req.send_http_header()
> >>   req.write( "mod python test \n hello world" )
> >>   return apache.OK
> >>
> >>
> >> .htaccess
> >>  AddHandler python-program .py
> >>  PythonHandler mpt
> >>  PythonDebug On
> > 
> > Only requests for which URL resolves to physical file with a .py extension
> > which be processed by mod_python which will in turn bump request
> > through to "mpt" handler.
> > 
> > Note that I intentionally say extension of physical file URL mapped to
> > as multiview matching rules can come into play. See link down further.

Whoops, need to correct a slight in accuracy in what I originally said.

That is, if the URL has a .py extension in first component of path,
a physical file doesn't have to exist.

The need for a physical file with .py extension only comes into play
when multiviews matching is attempted.

Also, if "MultiviewsMatch Handlers" is defined, you don't even need
a physical .py file for multiviews to work, as it will match purely based
on fact that .py is defined as the handler extension.

It's all a muddle, and one of these days I should write a proper mini
article on it all to clearly explain it, with examples. :-(

Graham


More information about the Mod_python mailing list