Conceptually I have something that looks like this:
+-------------+
| Clients |
| Web Browser |
+-------------+
| [http://somecooldomain.com/coorequest]
| ^
| | [Cool Response]
V |
+--------+ +------------+ +---------------+ +---------+
| Apache | --> | Mod_Python | --> | dispatcher.py | --> | cool.py | --+
| (A) | <-- | | <-- | (B) | | (D) | |
+--------+ +------------+ +---------------+ +---------+ |
| ^ |
| | |
| +------------------------+
V
+-------------+
| urlmap.conf |
| (C) |
+-------------+
A) Apache Configuration:
On my server I have mod_python set up to handle any request that comes in without a file extension. That way I can have those cool REST style URI's. I use the apache "FilesMatch" directive in my httpd.conf file to look for any request that does not contain a '.' before the '?' in the query string:
<FilesMatch "(^[^\.]*$|^[^\?]*[\?]+[^$]+$)">
SetHandler python-program
PythonHandler common.dispatch.dispatcher
PythonDebug On
</FilesMatch>
B) dispatcher.py
The source for dispatcher.py can be found here.
C) Example urlmap.conf
[somecooldomain.com]
/=cooldomain.handlers.home.handler
/signup=cooldomain.handlers.member.signup
/login=cooldomain.handlers.member.login
/logout=cooldomain.handlers.member.logout
/cool=cooldomain.handlers.cool.handler
D) cool.py
This is the handler that generates your content. In my content handlers I usually do things like query the database, process business logic, select a cheetah template and return the result as html.
In summary I use this approch for a couple of reasons, first it allows me to decouple my url's from my python code that way I don't have python code + html sitting around in the same directory. Secondly I get one piece of code that handles every request. (good for sessions and things like that)