summaryrefslogtreecommitdiff
path: root/Mailman/Utils.py
diff options
context:
space:
mode:
authorbwarsaw2000-08-01 21:55:52 +0000
committerbwarsaw2000-08-01 21:55:52 +0000
commitdac71163d82b6d990152adc7038b21e013071c92 (patch)
treefd9ecb74bca674026b001d0f35169b09e3847931 /Mailman/Utils.py
parentb20df5635aaa0d1740b9f827d3b018685c46e699 (diff)
downloadmailman-dac71163d82b6d990152adc7038b21e013071c92.tar.gz
mailman-dac71163d82b6d990152adc7038b21e013071c92.tar.zst
mailman-dac71163d82b6d990152adc7038b21e013071c92.zip
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r--Mailman/Utils.py35
1 files changed, 23 insertions, 12 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index b762a4422..321609293 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -32,6 +32,7 @@ from types import StringType
# XXX: obsolete, should use re module
import regsub
import random
+import urlparse
from Mailman import mm_cfg
from Mailman import Errors
@@ -219,18 +220,28 @@ def GetPathPieces(path):
return l
-_nesting_level = None
-def GetNestingLevel():
- global _nesting_level
- if _nesting_level == None:
- try:
- path = os.environ['PATH_INFO']
- if path[0] <> '/':
- path= '/' + path
- _nesting_level = string.count(path, '/')
- except KeyError:
- _nesting_level = 0
- return _nesting_level
+def ScriptURL(target, web_page_url=mm_cfg.DEFAULT_URL, absolute=0):
+ """target - scriptname only, nothing extra
+ web_page_url - the list's configvar of the same name
+ absolute - a flag which if set, generates an absolute url
+ """
+ fullpath = os.environ.get('REQUEST_URI')
+ if fullpath is None:
+ fullpath = os.environ.get('SCRIPT_NAME', '') + \
+ os.environ.get('PATH_INFO', '')
+ baseurl = urlparse.urlparse(web_page_url)[2]
+ if not absolute and fullpath[:len(baseurl)] == baseurl:
+ # Use relative addressing
+ fullpath = fullpath[len(baseurl):]
+ i = string.find(fullpath, '?')
+ if i > 0:
+ count = string.count(fullpath, '/', 0, i)
+ else:
+ count = string.count(fullpath, '/')
+ path = ('../' * count) + target
+ else:
+ path = web_page_url + target
+ return path + mm_cfg.CGIEXT