[mod_python] eliminating last foo.py from url?

Graham Dumpleton grahamd at dscpl.com.au
Mon Dec 18 19:55:43 EST 2006

Mark Harrison wrote ..
> Graham Dumpleton wrote:
> > Since you are setting the PythonPath directive to where your module file
> is
> > potentially installed anyway, you are possibly just better of using:
> > 
> >   # Move your stuff out of the document tree and you will not need this.
> > 
> >   <Directory "/Users/mh/mp/htdocs/xmlrpc/x1">
> >      deny from all
> >   </Directory>
> > 
> >   # Use Location instead of Directory.
> > 
> >   <Location /x1>
> >      # The PythonPath may have to be adjusted.
> >      PythonPath "sys.path+['/Users/mh/mp/htdocs/xmlrpc','/Users/mh/mp/htdocs/xmlrpc/x1']"
> >      SetHandler mod_python
> >      PythonHandler x1
> >   </Location>
> > 
> > By using Location directive, and with location itself not having trailing
> slash,
> > Apache will not do trailing slash redirection and just pass any request
> starting
> > with /x1 through to your handler.
> Ah, <Location> looks preferable to <Directory>, since then I don't have
> to install
> the python files under htdocs, but can instead point them to our build
> tree.
> But it's strange, even <Location> requires a trailing slash.  If I have
> too
> hard of a time getting clients to include it then I'll add the Alias.

Strange, as it shouldn't. Only thing I can think of is that the path you are
choosing for the Location directive still has a corresponding physical
directory of the same path under the document root and that is confusing
Apache and it is still wanting to do trailing slash redirection before it
matches it against the Location directive.

> BTW, apache+mod_python seems to be a nice xmlrpc platform.
> When I get this polished, I'll try and get permission to put a note on
> the
> wiki about setting it up.

You may want to have a look at my Vampire package which contains an
XML-RPC service endpoint for use in mod_python. All you need to do
is something like:

class _Object:

  def method1(self):
    return "method1"

  def method2(self,req):
    return "method2"

  def method3(self,req,arg):
    return "method3"

_object = _Object()

handler = vampire.Service(_object)

Unlike other XML-RPC endpoints for mod_python that I have seen, it still
gives you optional access to the request object if for example you wanted
to modify behaviour based on client IP etc.

Bit more information on this at:


I've done a lot of stuff with XML-RPC and other RPC over HTTP protocols
over the years, as well as other sorts of RPC messaging protocols over
distributed messaging systems. I can't point you to some of this other
stuff if there is any interest.


More information about the Mod_python mailing list