[mod_python] Templaing question

Graham Dumpleton grahamd at dscpl.com.au
Sun Mar 5 16:45:09 EST 2006

Michael Guerrero wrote ..
> On Sun, 2006-03-05 at 16:24 -0500, Graham Dumpleton wrote:
> > BTW, you are using "index" for name of function suggesting you are
> > using publisher. If you are using publisher, are you using SetHandler
> > or AddHandler?
> > 
> > If you use SetHandler so that all requests to the directory go through
> > publisher, it will mean that your stylesheet request will also go through
> > publisher. It will not be able to satisfy the request and will return
> not
> > found. Browsers tend to ignore not found errors on stylesheets and
> > do not show an error.
> > 
> > Thus, if you must use SetHandler, include in your configuration:
> > 
> >   <Files *.css>
> >   SetHandler default-handler
> >   </Files>
> > 
> > Graham
> Just as I received this second response it donned on me that 1) it was
> working earlier, and 2) the only change I made was from AddHandler to
> SetHandler (yes, I'm using publisher).  
> Thanks for the config fix Graham.  Also, you said "if you must use
> SetHandler...".  I'm only using it because the examples showed it.  Is
> it preferable to use AddHandler instead?  Pros/Cons?

If you use SetHandler with mod_python.publisher, you can't put other
types of files in the same directory, except by reseting to default
handler explicitly for them as I described. You must use SetHandler
though if you want access against the directory itself to automatically
map to "index.py/index". In general using no extensions and application
of MultiViews also only works well when using SetHandler.

If using AddHandler, you generally are stuck with using a specific
extension in your URLs to map to the files containing any published
functions etc. Usually people use ".py" for this purpose. This means
the URLs don't follow REST conventions. There is also the issue that
use of ".py" reveals that you are using Python and makes it harder
to transparently change to some other system later. Using AddHandler
makes it easier to mix other static files in the directory though.


More information about the Mod_python mailing list