summaryrefslogtreecommitdiff
path: root/Mailman/Utils.py
diff options
context:
space:
mode:
authorhmeland1999-03-02 12:40:56 +0000
committerhmeland1999-03-02 12:40:56 +0000
commit3bbf868d4f5ab576397ed554d839f31f190e4abe (patch)
treeb442b35a7ddbee161ab75fbfa594218ec4b9eb18 /Mailman/Utils.py
parent1c69356864aabc95b209457c556419da6acce332 (diff)
downloadmailman-3bbf868d4f5ab576397ed554d839f31f190e4abe.tar.gz
mailman-3bbf868d4f5ab576397ed554d839f31f190e4abe.tar.zst
mailman-3bbf868d4f5ab576397ed554d839f31f190e4abe.zip
Utils.GetRequestURI(): New function, returns the full virtual path the
calling CGI script was invoked with. Uses (non-standard, but convenient) environment variable REQUEST_URI when available, otherwise SCRIPT_NAME and PATH_INFO (which are part of the CGI/1.1 spec) if available, or simply returns optional argument `fallback' (which defaults to None). Cgi/admin.py, Cgi/admindb.py: Use it when generating admin authentication page.
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r--Mailman/Utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index b9dc4a44b..d79d3543a 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -664,3 +664,22 @@ def open_ex(filename, mode='r', bufsize=-1, perms=0664):
reraise(IOError, e)
finally:
os.umask(ou)
+
+def GetRequestURI(fallback=None):
+ """Return the full virtual path this CGI script was invoked with.
+
+ Newer web servers seems to supply this info in the REQUEST_URI
+ environment variable -- which isn't part of the CGI/1.1 spec.
+ Thus, if REQUEST_URI isn't available, we concatenate SCRIPT_NAME
+ and PATH_INFO, both of which are part of CGI/1.1.
+
+ Optional argument `fallback' (default `None') is returned if both of
+ the above methods fail.
+
+ """
+ if os.environ.has_key('REQUEST_URI'):
+ return os.environ['REQUEST_URI']
+ elif os.environ.has_key('SCRIPT_NAME') and os.environ.has_key('PATH_INFO'):
+ return os.environ['SCRIPT_NAME'] + os.environ['PATH_INFO']
+ else:
+ return fallback