[Harald Meland]
Please bear in mind that this is the first time I'm trying to do any CGI-related programming at all, but I still _think_ this patch is good (from reading the CGI/1.1 spec, and testing quickly that it doesn't break my web interface).
I was slightly wrong about the patch being perfectly good -- the Utils.CGIpath() function would, if both of the "proper" methods for getting at the path failed, fall back to ("/mailman/admin/" + list_name), regardless of which CGI script called it. This would, obviously, be wrong if called from e.g. "admindb".
It could also be argued that referencing the (hopefully defined) global variable list_name from CGIpath() is unnecessarily risky.
Below is a patch (against current CVS) which fixes these problems by operating in a manner very similar to os.environ.get(), i.e. letting the caller supply the complete fallback value.
[ I'm not really sure that putting a pretty special-purpose function like CGIpath() into the generic Utils module is the Right Thing -- but I couldn't see anywhere else where it would fit better. ]
RCS file: /projects/cvsroot/mailman/Mailman/Utils.py,v retrieving revision 1.62 diff -u -r1.62 Utils.py --- Utils.py 1999/01/14 04:07:28 1.62 +++ Utils.py 1999/02/24 20:26:00 @@ -664,3 +664,22 @@ reraise(IOError, e) finally: os.umask(ou)
+def CGIpath(env, fallback=None):
fallback' (default
None') is returned if return env["REQUEST_URI"]
return (env["SCRIPT_NAME"] + env["PATH_INFO"])
return fallback
RCS file: /projects/cvsroot/mailman/Mailman/Cgi/admin.py,v retrieving revision 1.31 diff -u -r1.31 admin.py --- admin.py 1999/01/09 05:57:17 1.31 +++ admin.py 1999/02/24 20:26:01 @@ -123,8 +123,8 @@ text = Utils.maketext( 'admlogin.txt', {"listname": list_name,
"path" : os.environ.get("REQUEST_URI",
'/mailman/admin/' + list_name),
"path" : Utils.CGIpath(os.environ,
'/mailman/admin/' + list_name),
"message" : message,
})
print text
RCS file: /projects/cvsroot/mailman/Mailman/Cgi/admindb.py,v retrieving revision 1.9 diff -u -r1.9 admindb.py --- admindb.py 1999/01/09 06:22:44 1.9 +++ admindb.py 1999/02/24 20:26:01 @@ -112,8 +112,8 @@ text = Utils.maketext( 'admlogin.txt', {'listname': list_name,
'path' : os.environ.get('REQUEST_URI',
'/mailman/admindb/' + list_name),
'path' : Utils.CGIpath(os.environ,
'/mailman/admindb/' + list_name),
'message' : message,
})
print text