[mod_python] Publisher handler-like URLs in CGI?

Graham Dumpleton grahamd at dscpl.com.au
Thu Dec 21 23:13:18 EST 2006


Anthony wrote ..
> Something I love about mod_python is the way the Publisher handler
> allow one to expose a function within a module as a URL.

If only you knew what problems it has. :-)

In other words, it certainly is one way of doing things, but the implementation
does have various problems/quirks with trailing slashes.

> Does anyone
> know if it's possible to get this functionality on CGI so that the
> following is allowed?
> 
> processing() in app.py ---> http://site.com/app.py/processing/

It would certainly be possible to implement something that would work within
CGI and am pretty sure that you probably find that someone else has actually
done it already.

> photoalbum() in index.py ---> http://site.com/photoalbum/

This variation you probably wouldn't be able to achieve except by resorting
to using some mod_rewrite magic as default mapping to CGI excepts the
name of the cgi program file to be present in the URL.

> And a little less on topic, could this be done if mod_python were not
> available, say if you were accessing python via CGI/FastCGI on Apache?

In doing it for CGI, you would not be able to rely on mod_python, so must be a
separate solution.

Anyway, search around on the net, there are lots of other solutions for
URL mapping in Python. You might even find a WSGI solution which does
it and which can work within CGI.

Graham


More information about the Mod_python mailing list