[mod_python] How to get the URI base of a mod_python app

Damjan gdamjan at mail.net.mk
Fri Jun 18 20:07:41 EDT 2004


I have a mod_python app setup like this:

Alias /mptest /home/www/mptest
<Directory /home/www/mptest>
  SetHandler mod_python
  PythonDebug On
  PythonHandler mptest
</Directory>

Offcourse the "/mptest" alias could be changed any time..

I'd like to get the URI base in my app no mather what the URL
was when the app was called (for ex. the app can be invoked with
/mptest/aaa/cccc/bbbbb?...).

I currently use this hack, but I'm not sure if it's the most accurate
way:

	i = req.uri.replace(req.path_info,'').rindex('/')
	uri_base = req.uri[:i].decode('utf-8')


-- 
damjan | дамјан
This is my jabber ID --> damjan at bagra.net.mk <-- not my mail address!!!


More information about the Mod_python mailing list