Skip to content

Commit dea13ae

Browse files
author
Richard Jones
committed
fixed various URL / base URL issues
1 parent 9d15d95 commit dea13ae

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ are given with the most recent entry first.
88
. registration error punts back to register page
99
. gadfly backend now handles changes to the schema - but only one property
1010
at a time
11+
. cgi.client base URL is now obtained from the config TRACKER_WEB
12+
. request.url has gone away - there's too much magic in trying to figure
13+
what it should be
14+
. cgi-bin script redirects to https now if the request was https
1115

1216

1317
2002-09-13 0.5.0 beta2

TODO.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pending web UNIX init.d script for roundup-server
4949
pending web allow multilink selections to select a "none" element to allow
5050
people with broken browsers to select nothing?
5151

52-
bug web request.url is incorrect in cgi-bin environments
5352
bug web do something about file.newitem
5453
bug mailgw some f*ked mailers QUOTE their Re; "Re: "[issue1] bla blah""
5554
bug docs need to mention somewhere how sorting works

cgi-bin/roundup.cgi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup.cgi,v 1.31 2002-09-10 03:01:17 richard Exp $
19+
# $Id: roundup.cgi,v 1.32 2002-09-16 22:37:26 richard Exp $
2020

2121
# python version check
2222
from roundup import version_check
@@ -140,7 +140,12 @@ def main(out, err):
140140
# redirect if we need a trailing '/'
141141
if len(path) == 2:
142142
request.send_response(301)
143-
absolute_url = 'http://%s%s/'%(os.environ['HTTP_HOST'],
143+
# redirect
144+
if os.environ.get('HTTPS', '') == 'on':
145+
protocol = 'https'
146+
else:
147+
protocol = 'http'
148+
absolute_url = '%s://%s%s/'%(protocol, os.environ['HTTP_HOST'],
144149
os.environ['REQUEST_URI'])
145150
request.send_header('Location', absolute_url)
146151
request.end_headers()

roundup/cgi/client.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.36 2002-09-16 06:39:12 richard Exp $
1+
# $Id: client.py,v 1.37 2002-09-16 22:37:26 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -63,8 +63,7 @@ class Client:
6363
keeps the nodeid of the session as the "session" attribute.
6464
6565
Client attributes:
66-
"url" is the current url path
67-
"path" is the PATH_INFO inside the instance
66+
"path" is the PATH_INFO inside the instance (with no leading '/')
6867
"base" is the base URL for the instance
6968
'''
7069

@@ -74,31 +73,28 @@ def __init__(self, instance, request, env, form=None):
7473
self.request = request
7574
self.env = env
7675

76+
# save off the path
7777
self.path = env['PATH_INFO']
78-
self.split_path = self.path.split('/')
79-
self.instance_path_name = env['TRACKER_NAME']
8078

8179
# this is the base URL for this instance
82-
url = self.env['SCRIPT_NAME'] + '/' + self.instance_path_name
83-
self.base = urlparse.urlunparse(('http', env['HTTP_HOST'], url,
84-
None, None, None))
85-
86-
# request.path is the full request path
87-
x, x, path, x, x, x = urlparse.urlparse(request.path)
88-
self.url = urlparse.urlunparse(('http', env['HTTP_HOST'], path,
89-
None, None, None))
80+
self.base = self.instance.config.TRACKER_WEB
9081

82+
# see if we need to re-parse the environment for the form (eg Zope)
9183
if form is None:
9284
self.form = cgi.FieldStorage(environ=env)
9385
else:
9486
self.form = form
95-
self.headers_done = 0
87+
88+
# turn debugging on/off
9689
try:
9790
self.debug = int(env.get("ROUNDUP_DEBUG", 0))
9891
except ValueError:
9992
# someone gave us a non-int debug level, turn it off
10093
self.debug = 0
10194

95+
# flag to indicate that the HTTP headers have been sent
96+
self.headers_done = 0
97+
10298
# additional headers to send with the request - must be registered
10399
# before the first write
104100
self.additional_headers = {}
@@ -277,7 +273,7 @@ def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')):
277273
self.nodeid = None
278274

279275
# determine the classname and possibly nodeid
280-
path = self.split_path
276+
path = self.path.split('/')
281277
if not path or path[0] in ('', 'home', 'index'):
282278
if self.form.has_key(':template'):
283279
self.template = self.form[':template'].value

roundup/cgi/templating.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,6 @@ class HTMLRequest:
11531153
11541154
"form" the CGI form as a cgi.FieldStorage
11551155
"env" the CGI environment variables
1156-
"url" the current URL path for this request
11571156
"base" the base URL for this instance
11581157
"user" a HTMLUser instance for this user
11591158
"classname" the current classname (possibly None)
@@ -1177,7 +1176,6 @@ def __init__(self, client):
11771176
self.form = client.form
11781177
self.env = client.env
11791178
self.base = client.base
1180-
self.url = client.url
11811179
self.user = HTMLUser(client, 'user', client.userid)
11821180

11831181
# store the current class name and action

0 commit comments

Comments
 (0)