def ScriptURL(target, web_page_url=None, absolute=False): """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 """ if web_page_url is None: web_page_url = mm_cfg.DEFAULT_URL_PATTERN % get_domain() if web_page_url[-1] <> '/': web_page_url = web_page_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.endswith(baseurl): ^^^^^^^^^^^^^^^^^ # Use relative addressing fullpath = fullpath[len(baseurl):] i = fullpath.find('?') if i > 0: count = fullpath.count('/', 0, i) else: count = fullpath.count('/') path = ('../' * count) + target else: path = web_page_url + target return path + mm_cfg.CGIEXT
I'm curious about the "if not absolute ..." test in the code above. Is it possible that the author really wanted
if not absolute and fullpath.startswith(baseurl):
?
This would seem to make more sense to me, since the test is presumably there to check whether a relative URL can be constructed. This would seemingly need the LEADING (not the TRAILING) part of "fullpath" to be "baseurl".
Also given the code in the "then" clause, which apparently (and understandably) wants to strip the "baseurl" part out of "fullpath", I'd expect the startswith method to be used in the if.
Finally, the entire reason I'm looking at this is that a local user complained about the link individual lists on the mailing list overview page being absolute URIs. Changing "endswith" to "startswith" does the trick...
On the other hand, I'm not familiar with the mailman code, nor am I a python programmer, so perhaps I'm missing something...?
TIA!,
- Richard Geiger rmg@datadomain.com