| Adrian Holovaty 
    modpython at holovaty.com Tue Jan 13 11:30:17 EST 2004 
 Is there a way of passing the relative URL (relative to the httpd.conf 
"Location") to a mod_python handler?
For instance, say I have the following in httpd.conf:
<Location "/admin">
    SetHandler python-program
    PythonHandler apps.admin.handler
</Location>
If the client goes to /admin/storyeditor, how do I give mod_python access to 
the part of the URL that comes after "/admin"?. Ideally the handler wouldn't 
have to know that it was tied to /admin, so I could switch that to, say, 
/administration, and I'd just have to change it in httpd.conf.
I'm currently solving this problem by passing "/admin" to the handler via a 
PythonOption, then using this bit of handler code to get the relative path:
root_location = req.get_options()['rootpath']
relative_path = req.uri[len(root_location):]
That works, but it seems hackish. Is there a cleaner way to do it?
Adrian
 |