[mod_python] eliminating last foo.py from url?

Graham Dumpleton grahamd at dscpl.com.au
Mon Dec 18 05:49:08 EST 2006


Mark Harrison wrote ..
> Mark Harrison wrote:
> > So, I've pretty much copied the standard directory configuration,
> > 
> > <Directory "/apache/htdocs/appserv">
> >         AddHandler mod_python .py
> >         PythonHandler appserv
> >         PythonDebug On
> > </Directory>
> > 
> > and I can reference my service by http://foo.com/appserv/appserv.py
> > (or any other .py in that directory, of course).
> > 
> > How can I make it such that I can reference with the trailing foo.py?
> 
> Alias seems to be the key...
> 
> <Directory "/Users/mh/mp/htdocs/xmlrpc/x1">
>    AddHandler mod_python .py
>    PythonHandler x1
> </Directory>
> Alias /x1 /Users/mh/mp/htdocs/xmlrpc/x1/.py

As indicated in previous response on list, the DirectoryIndex directive is more
appropriate for having directory access mapped to a mod_python handler when
you are using AddHandler rather than SetHandler. I would recommend against
trying to fiddle things with an Alias directive as it will not work for subdirectories
and that your left hand side doesn't use a trailing slash may cause other issues
as well with base url determination and relative URLs in HTML files which can
cause problems with your web application.

Why can't you use the following?

  <Directory "/Users/mh/mp/htdocs/xmlrpc/x1">
     AddHandler mod_python .py
     PythonHandler x1
     # Value to DirectoryIndex should be anything with .py
     # extension, it does not actually have to exist.
     DirectoryIndex index.py
  </Directory>

  Alias /x1 /Users/mh/mp/htdocs/xmlrpc/x1

Did you read the article referenced in prior replies? Namely:

  http://www.dscpl.com.au/wiki/ModPython/Articles/SetHandlerVersusAddHandler

and which talks about using DirectoryIndex when using AddHandler.

Graham


More information about the Mod_python mailing list