From 4ad45896c72a22cdb1803084ca24f55b960811ad Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 16 Sep 2002 22:37:26 +0000 Subject: [PATCH] fixed various URL / base URL issues git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1181 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 4 ++++ TODO.txt | 1 - cgi-bin/roundup.cgi | 9 +++++++-- roundup/cgi/client.py | 26 +++++++++++--------------- roundup/cgi/templating.py | 2 -- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d177817..35168b8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,10 @@ are given with the most recent entry first. . registration error punts back to register page . gadfly backend now handles changes to the schema - but only one property at a time + . cgi.client base URL is now obtained from the config TRACKER_WEB + . request.url has gone away - there's too much magic in trying to figure + what it should be + . cgi-bin script redirects to https now if the request was https 2002-09-13 0.5.0 beta2 diff --git a/TODO.txt b/TODO.txt index 6122bfe..4228c9e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -49,7 +49,6 @@ pending web UNIX init.d script for roundup-server pending web allow multilink selections to select a "none" element to allow people with broken browsers to select nothing? -bug web request.url is incorrect in cgi-bin environments bug web do something about file.newitem bug mailgw some f*ked mailers QUOTE their Re; "Re: "[issue1] bla blah"" bug docs need to mention somewhere how sorting works diff --git a/cgi-bin/roundup.cgi b/cgi-bin/roundup.cgi index 8032705..2fb844d 100755 --- a/cgi-bin/roundup.cgi +++ b/cgi-bin/roundup.cgi @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup.cgi,v 1.31 2002-09-10 03:01:17 richard Exp $ +# $Id: roundup.cgi,v 1.32 2002-09-16 22:37:26 richard Exp $ # python version check from roundup import version_check @@ -140,7 +140,12 @@ def main(out, err): # redirect if we need a trailing '/' if len(path) == 2: request.send_response(301) - absolute_url = 'http://%s%s/'%(os.environ['HTTP_HOST'], + # redirect + if os.environ.get('HTTPS', '') == 'on': + protocol = 'https' + else: + protocol = 'http' + absolute_url = '%s://%s%s/'%(protocol, os.environ['HTTP_HOST'], os.environ['REQUEST_URI']) request.send_header('Location', absolute_url) request.end_headers() diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index c7a2e79..831ac7a 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.36 2002-09-16 06:39:12 richard Exp $ +# $Id: client.py,v 1.37 2002-09-16 22:37:26 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -63,8 +63,7 @@ class Client: keeps the nodeid of the session as the "session" attribute. Client attributes: - "url" is the current url path - "path" is the PATH_INFO inside the instance + "path" is the PATH_INFO inside the instance (with no leading '/') "base" is the base URL for the instance ''' @@ -74,31 +73,28 @@ class Client: self.request = request self.env = env + # save off the path self.path = env['PATH_INFO'] - self.split_path = self.path.split('/') - self.instance_path_name = env['TRACKER_NAME'] # this is the base URL for this instance - url = self.env['SCRIPT_NAME'] + '/' + self.instance_path_name - self.base = urlparse.urlunparse(('http', env['HTTP_HOST'], url, - None, None, None)) - - # request.path is the full request path - x, x, path, x, x, x = urlparse.urlparse(request.path) - self.url = urlparse.urlunparse(('http', env['HTTP_HOST'], path, - None, None, None)) + self.base = self.instance.config.TRACKER_WEB + # see if we need to re-parse the environment for the form (eg Zope) if form is None: self.form = cgi.FieldStorage(environ=env) else: self.form = form - self.headers_done = 0 + + # turn debugging on/off try: self.debug = int(env.get("ROUNDUP_DEBUG", 0)) except ValueError: # someone gave us a non-int debug level, turn it off self.debug = 0 + # flag to indicate that the HTTP headers have been sent + self.headers_done = 0 + # additional headers to send with the request - must be registered # before the first write self.additional_headers = {} @@ -277,7 +273,7 @@ class Client: self.nodeid = None # determine the classname and possibly nodeid - path = self.split_path + path = self.path.split('/') if not path or path[0] in ('', 'home', 'index'): if self.form.has_key(':template'): self.template = self.form[':template'].value diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index 2561b2b..465a403 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -1153,7 +1153,6 @@ class HTMLRequest: "form" the CGI form as a cgi.FieldStorage "env" the CGI environment variables - "url" the current URL path for this request "base" the base URL for this instance "user" a HTMLUser instance for this user "classname" the current classname (possibly None) @@ -1177,7 +1176,6 @@ class HTMLRequest: self.form = client.form self.env = client.env self.base = client.base - self.url = client.url self.user = HTMLUser(client, 'user', client.userid) # store the current class name and action -- 2.30.2