[mod_python] errors in default mod_python docs for 3.2.10 publisher setup

Graham Dumpleton grahamd at dscpl.com.au
Fri Sep 1 21:30:47 EDT 2006

On 01/09/2006, at 12:01 PM, Blair P. Houghton wrote:

> I happened to get frustrated enough to plug the right magic
> into the right search box (the one at http://modpython.org/,
> as Google wasn't helping) and found the answer to the reason
> that /my/ publisher setup wasn't finding my scripts.  The answer
> is that the setup I was following from the 3.2.10 doc tree is
> incomplete, and doesn't say that the URI for a publisher-mediated
> script has to include the name of the method being invoked.

It does, in as much as the example shows that is the case. It just does
not spell it out in words as a requirement. Ie., it always uses  

> I.e., this document is inadequate:
> http://www.modpython.org/live/mod_python-3.2.10/doc-html/tut-pub.html
> the three .conf lines are correct, but the description omits the
> correct URI formula.  Just browsing to http://domain/path/script
> or http://domain/path/script.py gets a 404 error, while
> http://domain/path/script.py/handler works fine.

Referencing just the script and no function name will work provided that
the code file contains a function called index().

That you use a name "handler" suggests you are getting a bit muddled
with the difference between basic mod_python handlers, where response
handler is always called handler() and name of function doesn't need  
to be
in the URL and mod_python.publisher where with the exception of index(),
the function does have to be in the URL.

> Note that the
> '.py' suffix must be included also.

Not necessarily. Whether this is the case will depend on how Apache is
configured for MultiViews. Try the configuration:

   AddHandler mod_python .py
   PythonHandler mod_python.publisher
   PythonDebug On

   Options +MultiViews
   MultiviewsMatch Handlers

   AddType text/html;qs=1.0 .py
   AddType text/html;qs=0.9 .html
   AddType text/plain;qs=0.8 .txt

On mod_python web site, do searches for "MultiViews MultiviewsMatch" and
"MultiviewsMatch DirectoryIndex" for other discussions on this topic.  
which include most are probably:


> This document has a different .conf, but does give
> the correct instructions for the URI:
> http://www.modpython.org/live/current/doc-html/hand-pub-intro.html
> Okay.  For grins I just tried the second .conf setup, and
> now it works with or without the '.py' suffix, but the
> handler name is still required.*
> I have not tested any PATH environment-variable variations.  I do  
> know that I have one installation (the XAMPP bundle on Win XP) that  
> does not need any explicit Python elements in the PATH at all.  How  
> that works I don't know.  But this one (the DeveloperSide.net  
> bundle, with mod_python added on afterward...I forget whose  
> mod_python build it was, I'm pretty sure I got it from a  
> modpython.org mirror).
> I believe that the document from the live/current tree should be  
> moved to the document in the live/mod_python-
> 3.2.10 tree ASAP so that people won't be caught by this any more.

Those two trees are the same document, just different parts of the  
same document.
Both AddHandler and SetHandler approaches can work, but they are used  
different reasons.


> I'd do it myself but I'm not even sure that this email will get  
> through so I'm not quite up to speed on monkeying around the  
> project files, nor even if they're modifiable by mod_python newbs.   
> Another of the pleasures of open source.
> --Blair
> * - here are the significant lines from the working .conf:
>  LoadModule python_module modules/mod_python.so
>  <Directory /www/webroot>
>    SetHandler mod_python    PythonHandler mod_python.publisher
>  </Directory>
> The path "modules/mod_python.so" is
> relative to the Apache install directory; in this case
> the full path is C:/www/Apache22/modules/mod_python.so".
> "/www/webroot" is the base of my served-file tree, so it
> could have been just "/" or the Directory lines could
> be omitted entirely and the behavior is the same on my
> system.  The working URI is "http://localhost/script/handler".
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list