[mod_python] mod_python.publisher and MultiViews

Graham Dumpleton grahamd at dscpl.com.au
Fri Aug 12 01:43:21 EDT 2005

Anyone who reads my followups to questions asked here would
know I tend to recommend that one avoid the use of the MultiViews
option. This is especially the case if you are using SetHandler to
create a handler which handles all requests in a directory.

All the same, use of MultiViews is still popular with people using
AddHandler and mod_python.publisher so they can avoid having to use
".py" in the URL. The best configuration that one can use is:

  AddHandler mod_python .py
  PythonHandler mod_python.publisher
  PythonDebug On

  Options +MultiViews
  MultiviewsMatch Handlers

This would then allow one to use:


instead of:


This though still has problems where you have non ".py" files in the
same directory which share the same basename as a ".py" file but a
different extension.

For example, if you have a file "page.psp" in the same directory, all
still works okay for the above URL.

If however you add a file "page.html" or "page.txt" into the directory,
preference is given first to the ".html" file, next the ".txt".

In other words, the a handler for a specific extension has a lower
precedence than a physical ".html" or ".txt" file, yet the handler gets
precedence over a file type with an extension.

Why this occurs is all tied up with the weighting preference for different
file types as specified by the browser. For example:

  Accept: text/html; q=1.0, text/*; q=0.8

Plus I assume some parts of the Apache configuration itself.

The problem with this is that if the ".html" file is actually mean't to be
an input to some processing done by the handler, a request is going to
pick up the raw unprocessed ".html" file instead of running it through
the handler.

Such are some of the issues with using MultiViews. The simple fix is
to not use MultiViews and use ".py" extensions in the URLs, which is
what I suggest, and all the problems go away.

I would rather like to understand how one could configure Apache to
redefine the precedence order to always ensure the handler gets
precedence. Does this make sense? Is it possible?

Note, I don't actually use mod_python.publisher myself. I am purely
trying to understand this better so I might perhaps be able to give out
better answers to people when they ask about these issues.


More information about the Mod_python mailing list