Skip to content

Commit 869472a

Browse files
author
Richard Jones
committed
Many features and fixes.
. roundup-admin create now prompts for property info if none is supplied on the command-line. . hyperdb Class getprops() method may now return only the mutable properties. . Login now uses cookies, which makes it a whole lot more flexible. We can now support anonymous user access (read-only, unless there's an "anonymous" user, in which case write access is permitted). Login handling has been moved into cgi_client.Client.main() . The "extended" schema is now the default in roundup init. . The schemas have had their page headings modified to cope with the new login handling. Existing installations should copy the interfaces.py file from the roundup lib directory to their instance home. . Incorrectly had a Bizar Software copyright on the cgitb.py module from Ping - has been removed. . Fixed a whole bunch of places in the CGI interface where we should have been returning Not Found instead of throwing an exception. . Fixed a deviation from the spec: trying to modify the 'id' property of an item now throws an exception.
1 parent 295583b commit 869472a

File tree

9 files changed

+332
-129
lines changed

9 files changed

+332
-129
lines changed

CHANGES.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,34 @@ This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

44
2001-??-?? - 0.2.9
5+
Feature:
6+
. roundup-admin create now prompts for property info if none is supplied
7+
on the command-line.
8+
. hyperdb Class getprops() method may now return only the mutable
9+
properties.
10+
. CGI interfaces now generate a top-level index of their known instances.
11+
12+
Changed:
13+
. Login now uses cookies, which makes it a whole lot more flexible. We can
14+
now support anonymous user access (read-only, unless there's an
15+
"anonymous" user, in which case write access is permitted). Login
16+
handling has been moved into cgi_client.Client.main()
17+
. The "extended" schema is now the default in roundup init.
18+
. The schemas have had their page headings modified to cope with the new
19+
login handling. Existing installations should copy the interfaces.py
20+
file from the roundup lib directory to their instance home.
21+
522
Fixed:
23+
. Incorrectly had a Bizar Software copyright on the cgitb.py module from
24+
Ping - has been removed.
625
. Pretty time interval wasn't handling > 1 month properly.
726
. Generation of links to Link/Multilink in indexes. (thanks Hubert Hoegl)
827
. AssignedTo wasn't in the "classic" schema's item page.
9-
28+
. Fixed a whole bunch of places in the CGI interface where we should have
29+
been returning Not Found instead of throwing an exception.
30+
. Fixed a deviation from the spec: trying to modify the 'id' property of
31+
an item now throws an exception.
32+
. The plain() template function now html-escapes the content.
1033

1134
2001-08-30 - 0.2.8
1235
Fixed:

cgi-bin/roundup.cgi

Lines changed: 35 additions & 59 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.12 2001-10-01 05:55:41 richard Exp $
19+
# $Id: roundup.cgi,v 1.13 2001-10-05 02:23:24 richard Exp $
2020

2121
# python version check
2222
import sys
@@ -59,73 +59,46 @@ except:
5959
traceback.print_exc(None, s)
6060
print cgi.escape(s.getvalue()), "</pre>"
6161

62-
def main(instance, out):
63-
from roundup import cgi_client
64-
db = instance.open('admin')
65-
auth = os.environ.get("HTTP_CGI_AUTHORIZATION", None)
66-
message = 'Unauthorised'
67-
if auth:
68-
import binascii
69-
l = binascii.a2b_base64(auth.split(' ')[1]).split(':')
70-
user = l[0]
71-
password = None
72-
if len(l) > 1:
73-
password = l[1]
74-
try:
75-
uid = db.user.lookup(user)
76-
except KeyError:
77-
auth = None
78-
message = 'Username not recognised'
79-
else:
80-
if password != db.user.get(uid, 'password'):
81-
message = 'Incorrect password'
82-
auth = None
83-
if not auth:
84-
out.write('Content-Type: text/html\n')
85-
out.write('Status: 401\n')
86-
out.write('WWW-Authenticate: basic realm="Roundup"\n\n')
87-
keys = os.environ.keys()
88-
keys.sort()
89-
out.write(message)
90-
return
91-
client = instance.Client(out, db, os.environ, user)
92-
try:
93-
client.main()
94-
except cgi_client.Unauthorised:
95-
out.write('Content-Type: text/html\n')
96-
out.write('Status: 403\n\n')
97-
out.write('Unauthorised')
98-
99-
def index(out):
100-
''' Print up an index of the available instances
101-
'''
102-
import urllib
103-
w = out.write
104-
w("Content-Type: text/html\n\n")
105-
w('<html><head><title>Roundup instances index</title><head>\n')
106-
w('<body><h1>Roundup instances index</h1><ol>\n')
107-
for instance in ROUNDUP_INSTANCE_HOMES.keys():
108-
w('<li><a href="%s/index">%s</a>\n'%(urllib.quote(instance),
109-
instance))
110-
w('</ol></body></html>')
111-
112-
#
113-
# Now do the actual CGI handling
114-
#
115-
out, err = sys.stdout, sys.stderr
116-
try:
117-
sys.stdout = sys.stderr = LOG
62+
def main(out, err):
11863
import os, string
11964
import roundup.instance
12065
path = string.split(os.environ['PATH_INFO'], '/')
12166
instance = path[1]
67+
os.environ['INSTANCE_NAME'] = instance
12268
os.environ['PATH_INFO'] = string.join(path[2:], '/')
12369
if ROUNDUP_INSTANCE_HOMES.has_key(instance):
12470
instance_home = ROUNDUP_INSTANCE_HOMES[instance]
12571
instance = roundup.instance.open(instance_home)
126-
main(instance, out)
72+
from roundup import cgi_client
73+
client = instance.Client(instance, out, os.environ)
74+
try:
75+
client.main()
76+
except cgi_client.Unauthorised:
77+
out.write('Content-Type: text/html\n')
78+
out.write('Status: 403\n\n')
79+
out.write('Unauthorised')
80+
except cgi_client.NotFound:
81+
out.write('Content-Type: text/html\n')
82+
out.write('Status: 404\n\n')
83+
out.write('Not found: %s'%client.path)
12784
else:
128-
index(out)
85+
import urllib
86+
w = out.write
87+
w("Content-Type: text/html\n\n")
88+
w('<html><head><title>Roundup instances index</title><head>\n')
89+
w('<body><h1>Roundup instances index</h1><ol>\n')
90+
for instance in ROUNDUP_INSTANCE_HOMES.keys():
91+
w('<li><a href="%s/index">%s</a>\n'%(urllib.quote(instance),
92+
instance))
93+
w('</ol></body></html>')
94+
95+
#
96+
# Now do the actual CGI handling
97+
#
98+
out, err = sys.stdout, sys.stderr
99+
try:
100+
sys.stdout = sys.stderr = LOG
101+
main(out, err)
129102
except:
130103
sys.stdout, sys.stderr = out, err
131104
out.write('Content-Type: text/html\n\n')
@@ -135,6 +108,9 @@ sys.stdout, sys.stderr = out, err
135108

136109
#
137110
# $Log: not supported by cvs2svn $
111+
# Revision 1.12 2001/10/01 05:55:41 richard
112+
# Fixes to the top-level index
113+
#
138114
# Revision 1.11 2001/09/29 13:27:00 richard
139115
# CGI interfaces now spit up a top-level index of all the instances they can
140116
# serve.

roundup-admin

Lines changed: 11 additions & 3 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-admin,v 1.20 2001-10-04 02:12:42 richard Exp $
19+
# $Id: roundup-admin,v 1.21 2001-10-05 02:23:24 richard Exp $
2020

2121
import sys
2222
if int(sys.version[0]) < 2:
@@ -119,9 +119,9 @@ def do_init(instance_home, args):
119119
if template not in templates:
120120
print 'Templates:', ', '.join(templates)
121121
while template not in templates:
122-
template = raw_input('Select template [classic]: ').strip()
122+
template = raw_input('Select template [extended]: ').strip()
123123
if not template:
124-
template = 'classic'
124+
template = 'extended'
125125

126126
import roundup.backends
127127
backends = roundup.backends.__all__
@@ -449,6 +449,14 @@ if __name__ == '__main__':
449449

450450
#
451451
# $Log: not supported by cvs2svn $
452+
# Revision 1.20 2001/10/04 02:12:42 richard
453+
# Added nicer command-line item adding: passing no arguments will enter an
454+
# interactive more which asks for each property in turn. While I was at it, I
455+
# fixed an implementation problem WRT the spec - I wasn't raising a
456+
# ValueError if the key property was missing from a create(). Also added a
457+
# protected=boolean argument to getprops() so we can list only the mutable
458+
# properties (defaults to yes, which lists the immutables).
459+
#
452460
# Revision 1.19 2001/10/01 06:40:43 richard
453461
# made do_get have the args in the correct order
454462
#

roundup-server

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
Based on CGIHTTPServer in the Python library.
2222
23-
$Id: roundup-server,v 1.12 2001-09-29 13:27:00 richard Exp $
23+
$Id: roundup-server,v 1.13 2001-10-05 02:23:24 richard Exp $
2424
2525
"""
2626
import sys
@@ -75,10 +75,12 @@ class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
7575
sys.stdin = self.rfile
7676
try:
7777
self.inner_run_cgi()
78+
except cgi_client.NotFound:
79+
self.send_error(404, self.path)
7880
except cgi_client.Unauthorised:
7981
self.wfile.write('Content-Type: text/html\n')
80-
self.wfile.write('Status: 403\n')
81-
self.wfile.write('Unauthorised')
82+
self.wfile.write('Status: 403\n\n')
83+
self.wfile.write('You are not authorised to access this URL.')
8284
except:
8385
try:
8486
reload(cgitb)
@@ -121,12 +123,12 @@ class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
121123
if rest == '/':
122124
return self.index()
123125
l_path = string.split(rest, '/')
124-
instance = urllib.unquote(l_path[1])
125-
if self.ROUNDUP_INSTANCE_HOMES.has_key(instance):
126-
instance_home = self.ROUNDUP_INSTANCE_HOMES[instance]
126+
instance_name = urllib.unquote(l_path[1])
127+
if self.ROUNDUP_INSTANCE_HOMES.has_key(instance_name):
128+
instance_home = self.ROUNDUP_INSTANCE_HOMES[instance_name]
127129
instance = roundup.instance.open(instance_home)
128130
else:
129-
return self.index()
131+
raise cgi_client.NotFound
130132

131133
# figure out what the rest of the path is
132134
if len(l_path) > 2:
@@ -136,6 +138,7 @@ class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
136138

137139
# Set up the CGI environment
138140
env = {}
141+
env['INSTANCE_NAME'] = instance_name
139142
env['REQUEST_METHOD'] = self.command
140143
env['PATH_INFO'] = urllib.unquote(rest)
141144
if query:
@@ -176,41 +179,12 @@ class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
176179
#finally:
177180
# del sys.path[0]
178181

179-
# initialise the roundupdb, check for auth
180-
db = instance.open('admin')
181-
message = 'Unauthorised'
182-
auth = self.headers.getheader('authorization')
183-
if auth:
184-
l = binascii.a2b_base64(auth.split(' ')[1]).split(':')
185-
user = l[0]
186-
password = None
187-
if len(l) > 1:
188-
password = l[1]
189-
try:
190-
uid = db.user.lookup(user)
191-
except KeyError:
192-
auth = None
193-
message = 'Username not recognised'
194-
else:
195-
if password != db.user.get(uid, 'password'):
196-
message = 'Incorrect password'
197-
auth = None
198-
db.close()
199-
del db
200-
if not auth:
201-
self.send_response(401)
202-
self.send_header('Content-Type', 'text/html')
203-
self.send_header('WWW-Authenticate', 'basic realm="Roundup"')
204-
self.end_headers()
205-
self.wfile.write(message)
206-
return
207-
208182
self.send_response(200, "Script output follows")
209183

210184
# do the roundup thang
211-
db = instance.open(user)
212-
client = instance.Client(self.wfile, db, env, user)
185+
client = instance.Client(instance, self.wfile, env)
213186
client.main()
187+
214188
do_POST = run_cgi
215189

216190
nobody = None
@@ -282,6 +256,10 @@ if __name__ == '__main__':
282256

283257
#
284258
# $Log: not supported by cvs2svn $
259+
# Revision 1.12 2001/09/29 13:27:00 richard
260+
# CGI interfaces now spit up a top-level index of all the instances they can
261+
# serve.
262+
#
285263
# Revision 1.11 2001/08/07 00:24:42 richard
286264
# stupid typo
287265
#

0 commit comments

Comments
 (0)