[mod_python] How to hide implementation specifics in URIs/URLs?

Matthew England mengland at mengland.net
Mon Jan 7 19:43:01 EST 2002


I'd like to be able to eliminate any web-server implementation specifics in 
my URIs/URLs as per 
<http://www.w3.org/Provider/Style/URI.html>.  Specifically, I'd like to 
eliminate the references to ".py" in my mod_python-managed URIs.  What are 
my apache options to do this?

These references:

<http://www.apacheweek.com/features/negotiation>
<http://httpd.apache.org/docs/content-negotiation.html>

...seem to be more interested in client-side-decision of content 
negotiation.  while this concept is interesting, and i might use it in the 
future, i'm not interested in this now.  i simply want to hide the 
server-side implemenation from my web user.

here's the basic algorithm i'm looking to implement in apache:

for said URI <http://myexampledomain.org/tickets/reserve>,

i would like apache to look in the [...]/tickets/ directory for a reserve.* 
file.  if there exists a [...]/tickets/reserve.py file, then apache 
immediately throws this .py file at the python handlers.  if there are 
multiple matches, ie, multiple files with the same 'reserve' but with 
different extensions, i want apache to decide what to do with the 
'ambiguous' URI by looking at a prioritized list of "content managers," 
probably a list specified by me in httpd.conf.  for example, i envision 
these lines placed in httpd.conf (and this is completely theoretical syntax):

ContentManager call-the-python-handler .py
ContentManager call-the-php-handler .php .php3
ContentManager call-the-cgi-handler .cgi

The order here is important, for .py files will be displayed/"managed" 
prior to .php or other files.  In my theoretical behavioral httpd.conf 
prototype syntax, i would have all unspecified extensions behave as they 
seem to "out of the box"...ie, whatever makes 
<http://192.168.1.50/~mengland/calendar> and 
<http://192.168.1.50/~mengland/calendar.html> do the same thing in my 
opera.com browser (maybe it's the same mechanism that i describe above?).

Notice how all of this stuff is totally managed by the server and requires 
no client-side input from the browser.  As I mentioned before, i'm not 
trying to have the client-side browser give language or media 
directives.  My main purpose is to keep my URIs clean and stable so that my 
users (and therefore much of my web server itself) don't have to change 
their URLs if i switch to some other underlying technology implementation 
(say if i switched from python to php for any segments of the web server).


disclaimer:

I'm constructing a web-database server for ticket reservations and am new 
to mod_python...and most everything else devshed.com-type-stuff-related.  I 
find openbsd-postgresql-python-apache to be the most attractive combination 
that i see now (openbsd for security purposes)...but since I'm new to these 
technologies, i'm far from certain of things yet.  I therefore apologize 
for any "newbie annoyance," or for a duplicate question.


thanks in advance for any help,
-Matt




More information about the Mod_python mailing list