LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   mod_python - is there an equivalent to $_SERVER['PHP_SELF'] in mod_python? (http://www.linuxquestions.org/questions/programming-9/mod_python-is-there-an-equivalent-to-%24_server%5Bphp_self%5D-in-mod_python-638527/)

BrianK 04-28-2008 08:49 PM

mod_python - is there an equivalent to $_SERVER['PHP_SELF'] in mod_python?
 
I'm making a mod_python/PSP page. That page lives in two places, a dev spot and a live spot. It includes a custom module that is also either dev or live. I want the dev version to include the dev module & the live version to include the live module.

in PHP, I check to see what $_SERVER['PHP_SELF'] is to determine which file to include. Is there a way to do that in mod_python?

if it matters, I want to do something like:
Code:

import sys,string
if string.find($_SERVER['PHP_SELF'],"dev") >= 0: # obviously, that doesn't work
  sys.path.append("/dev/module/path")
else:
  sys.path.append("/live/module/path")
import module

... but am open to suggestions.

BrianK 04-28-2008 08:57 PM

So I spent the last 2 hours searching for this answer, and of course, as soon as I post it here, I find the answer.

req.uri holds the uri.

Is there a list of all things in req? It's probably in the manual, I just haven't found it yet.

ntubski 04-28-2008 10:46 PM

Quote:

Originally Posted by BrianK (Post 3136111)
It's probably in the manual, I just haven't found it yet.

yup: 4.5.4 Request Object


All times are GMT -5. The time now is 01:41 AM.