Skip to content

Commit 6d64625

Browse files
author
Richard Jones
committed
CGI interfaces now spit up a top-level index of all instances they can serve.
1 parent b9f8358 commit 6d64625

File tree

4 files changed

+54
-30
lines changed

4 files changed

+54
-30
lines changed

cgi-bin/roundup.cgi

Lines changed: 18 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.cgi,v 1.10 2001-08-07 00:24:42 richard Exp $
19+
# $Id: roundup.cgi,v 1.11 2001-09-29 13:27:00 richard Exp $
2020

2121
# python version check
2222
import sys
@@ -97,6 +97,18 @@ def main(instance, out):
9797
out.write('Status: 403\n\n')
9898
out.write('Unauthorised')
9999

100+
def index(out):
101+
''' Print up an index of the available instances
102+
'''
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+
100112
#
101113
# Now do the actual CGI handling
102114
#
@@ -111,9 +123,9 @@ try:
111123
if ROUNDUP_INSTANCE_HOMES.has_key(instance):
112124
instance_home = ROUNDUP_INSTANCE_HOMES[instance]
113125
instance = roundup.instance.open(instance_home)
126+
main(instance, out)
114127
else:
115-
raise ValueError, 'No such instance "%s"'%instance
116-
main(instance, out)
128+
index()
117129
except:
118130
sys.stdout, sys.stderr = out, err
119131
out.write('Content-Type: text/html\n\n')
@@ -123,6 +135,9 @@ sys.stdout, sys.stderr = out, err
123135

124136
#
125137
# $Log: not supported by cvs2svn $
138+
# Revision 1.10 2001/08/07 00:24:42 richard
139+
# stupid typo
140+
#
126141
# Revision 1.9 2001/08/07 00:15:51 richard
127142
# Added the copyright/license notice to (nearly) all files at request of
128143
# Bizar Software.

roundup-server

Lines changed: 18 additions & 3 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.11 2001-08-07 00:24:42 richard Exp $
23+
$Id: roundup-server,v 1.12 2001-09-29 13:27:00 richard Exp $
2424
2525
"""
2626
import sys
@@ -94,6 +94,18 @@ class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
9494
self.wfile.write("</pre>\n")
9595
sys.stdin = save_stdin
9696

97+
def index(self):
98+
''' Print up an index of the available instances
99+
'''
100+
w = self.wfile.write
101+
w("Content-Type: text/html\n\n")
102+
w('<html><head><title>Roundup instances index</title><head>\n')
103+
w('<body><h1>Roundup instances index</h1><ol>\n')
104+
for instance in self.ROUNDUP_INSTANCE_HOMES.keys():
105+
w('<li><a href="%s/index">%s</a>\n'%(urllib.quote(instance),
106+
instance))
107+
w('</ol></body></html>')
108+
97109
def inner_run_cgi(self):
98110
''' This is the inner part of the CGI handling
99111
'''
@@ -107,14 +119,14 @@ class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
107119

108120
# figure the instance
109121
if rest == '/':
110-
raise ValueError, 'No instance specified'
122+
return self.index()
111123
l_path = string.split(rest, '/')
112124
instance = urllib.unquote(l_path[1])
113125
if self.ROUNDUP_INSTANCE_HOMES.has_key(instance):
114126
instance_home = self.ROUNDUP_INSTANCE_HOMES[instance]
115127
instance = roundup.instance.open(instance_home)
116128
else:
117-
raise ValueError, 'No such instance "%s"'%instance
129+
return self.index()
118130

119131
# figure out what the rest of the path is
120132
if len(l_path) > 2:
@@ -270,6 +282,9 @@ if __name__ == '__main__':
270282

271283
#
272284
# $Log: not supported by cvs2svn $
285+
# Revision 1.11 2001/08/07 00:24:42 richard
286+
# stupid typo
287+
#
273288
# Revision 1.10 2001/08/07 00:15:51 richard
274289
# Added the copyright/license notice to (nearly) all files at request of
275290
# Bizar Software.

roundup/backends/back_anydbm.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.7 2001-08-12 06:32:36 richard Exp $
18+
#$Id: back_anydbm.py,v 1.8 2001-09-29 13:27:00 richard Exp $
1919

2020
import anydbm, os, marshal
2121
from roundup import hyperdb, date
@@ -41,6 +41,7 @@ def __init__(self, storagelocator, journaltag=None):
4141
"""
4242
self.dir, self.journaltag = storagelocator, journaltag
4343
self.classes = {}
44+
self.transactions = []
4445

4546
#
4647
# Classes
@@ -203,21 +204,25 @@ def close(self):
203204
#
204205
# Basic transaction support
205206
#
206-
# TODO: well, write these methods (and then use them in other code)
207-
def register_action(self):
208-
''' Register an action to the transaction undo log
209-
'''
210-
211207
def commit(self):
212-
''' Commit the current transaction, start a new one
208+
''' Commit the current transactions.
213209
'''
210+
# lock the DB
211+
for action, classname, entry in self.transactions:
212+
# write the node, figure what's changed for the journal.
213+
pass
214+
# unlock the DB
214215

215216
def rollback(self):
216-
''' Reverse all actions from the current transaction
217+
''' Reverse all actions from the current transaction.
217218
'''
219+
self.transactions = []
218220

219221
#
220222
#$Log: not supported by cvs2svn $
223+
#Revision 1.7 2001/08/12 06:32:36 richard
224+
#using isinstance(blah, Foo) now instead of isFooType
225+
#
221226
#Revision 1.6 2001/08/07 00:24:42 richard
222227
#stupid typo
223228
#

roundup/cgitb.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
#
2-
# Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3-
# This module is free software, and you may redistribute it and/or modify
4-
# under the same terms as Python, so long as this copyright message and
5-
# disclaimer are retained in their original form.
6-
#
7-
# IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8-
# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9-
# OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10-
# POSSIBILITY OF SUCH DAMAGE.
11-
#
12-
# BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13-
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14-
# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15-
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16-
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
2+
# This module was written by Ka-Ping Yee, <[email protected]>.
173
#
18-
# $Id: cgitb.py,v 1.5 2001-08-07 00:24:42 richard Exp $
4+
# $Id: cgitb.py,v 1.6 2001-09-29 13:27:00 richard Exp $
195

206
import sys, os, types, string, keyword, linecache, tokenize, inspect, pydoc
217

@@ -132,6 +118,9 @@ def handler():
132118

133119
#
134120
# $Log: not supported by cvs2svn $
121+
# Revision 1.5 2001/08/07 00:24:42 richard
122+
# stupid typo
123+
#
135124
# Revision 1.4 2001/08/07 00:15:51 richard
136125
# Added the copyright/license notice to (nearly) all files at request of
137126
# Bizar Software.

0 commit comments

Comments
 (0)