[mod_python] Servlet and images.

Daniel Popowich dpopowich at comcast.net
Sun Sep 12 22:19:32 EDT 2004

FC writes:
> I'm playing with mod_python and the servlet module from Daniel Popowich 
> and I wanted to know how can I have python code and images in the same 
> directory.
> My htaccess file look like this:
> SetHandler mod_python
> PythonHandler mod_python.servlet
> PythonDebug on
> Apache try to run every file through the servelet module.

Yes, the handler will "process" every file, but if it's *not* a MPS
file the handler will return apache.DECLINED, telling apache that the
servlet handler is refusing this file and apache should do its normal
thing with this file.  The end result is that you can co-locate
MPS files with images, html, js, css, etc.; as long as it doesn't end
in ".mps" apache should do the correct thing.

You can also put "other" files in subdirectories and use "SetHandler
None" to get apache to not even call the python handler.  I assume
there's a performance boost doing it this way.

> I have also try to change SetHandler in my htaccess file to
> AddHander mod_python .mps and AddHandler mod_python .py but that
> doesn't work.

You can't use AddHandler with mpservlets.  The handler enforces
"clean" urls, in other words, if you have a file, /some/dir/foo.mps,
then the handler only allows referencing it with /some/dir/foo.

Daniel Popowich

More information about the Mod_python mailing list