[mod_python] does add_handler even work?

Graham Dumpleton grahamd at dscpl.com.au
Wed Oct 13 01:25:06 EDT 2004


On Oct 12 22:11, Scott Sanders <sanders at apache.org> wrote:
>
> Subject: Re: [mod_python] does add_handler even work?
>
> >
> > If I add a SetHandler, then everything works, but then other modules
> > like PHP and mod_autoindex stop working.
> >
> You either need to add the optional type after the SetHandler, or with 
> your AddHandler, your handler needs to return apache.DECLINED on 
> requests that you do not want to handle.

According to Apache documentation, you can't supply anything after the
SetHandler directive. If you do add something, you will get an internal
server error deriving from a misconfiguration of your configuration file.

The point of using SetHandler is to have every request under that directory
go through mod_python. This includes those with and without extensions.
Thus, it doesn't make sense to have an extension on SetHandler.

If you wanted to only process certain extensions, you would have used
AddHandler in the first place, which is what it is for. The problem is that the
AddHandler directive can't be used to intercept requests which don't have
any extension at all, thus why one ends up having to use SetHandler
if you want to catch those cases where there is no specific extension.

Having a content handler return apache.DECLINED doesn't help in the case
of PHP, because even though the request is passed back to Apache by
mod_python, the SetHandler directive seems to cause Apache not to
pass the file through the PHP module for processing. All it does when the
value apache.DECLINED is returned is return the raw PHP file, unprocessed.

This is why the solution seems to be to explicitly disable the SetHandler
altogether when the request is for a .php file. Ie.,

  SetHandler python-program
  PythonHandler vampire

  <Files *.php>
  SetHandler None
  </Files>

What happens when this is done, is that for a .php file, Apache doesn't even
bother handing off to mod_python and sends it direct to the PHP module.
Thus, returning apache.DECLINED isn't relevant anyway, as never gets to
that point.

Hopefully this more detailed explaination than my previous email is useful.

--
Graham Dumpleton (grahamd at dscpl.com.au)


More information about the Mod_python mailing list