comparison roundup-server @ 252:76c6994aa4e8

CGI interfaces now spit up a top-level index of all instances they can serve.
author Richard Jones <richard@users.sourceforge.net>
date Sat, 29 Sep 2001 13:27:00 +0000
parents 18134bffab37
children a671e5917b33
comparison
equal deleted inserted replaced
251:2f4123c715f1 252:76c6994aa4e8
18 # 18 #
19 """ HTTP Server that serves roundup. 19 """ HTTP Server that serves roundup.
20 20
21 Based on CGIHTTPServer in the Python library. 21 Based on CGIHTTPServer in the Python library.
22 22
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 $
24 24
25 """ 25 """
26 import sys 26 import sys
27 if int(sys.version[0]) < 2: 27 if int(sys.version[0]) < 2:
28 print "Content-Type: text/plain\n" 28 print "Content-Type: text/plain\n"
92 traceback.print_exc(None, s) 92 traceback.print_exc(None, s)
93 self.wfile.write(cgi.escape(s.getvalue())) 93 self.wfile.write(cgi.escape(s.getvalue()))
94 self.wfile.write("</pre>\n") 94 self.wfile.write("</pre>\n")
95 sys.stdin = save_stdin 95 sys.stdin = save_stdin
96 96
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
97 def inner_run_cgi(self): 109 def inner_run_cgi(self):
98 ''' This is the inner part of the CGI handling 110 ''' This is the inner part of the CGI handling
99 ''' 111 '''
100 112
101 rest = self.path 113 rest = self.path
105 else: 117 else:
106 query = '' 118 query = ''
107 119
108 # figure the instance 120 # figure the instance
109 if rest == '/': 121 if rest == '/':
110 raise ValueError, 'No instance specified' 122 return self.index()
111 l_path = string.split(rest, '/') 123 l_path = string.split(rest, '/')
112 instance = urllib.unquote(l_path[1]) 124 instance = urllib.unquote(l_path[1])
113 if self.ROUNDUP_INSTANCE_HOMES.has_key(instance): 125 if self.ROUNDUP_INSTANCE_HOMES.has_key(instance):
114 instance_home = self.ROUNDUP_INSTANCE_HOMES[instance] 126 instance_home = self.ROUNDUP_INSTANCE_HOMES[instance]
115 instance = roundup.instance.open(instance_home) 127 instance = roundup.instance.open(instance_home)
116 else: 128 else:
117 raise ValueError, 'No such instance "%s"'%instance 129 return self.index()
118 130
119 # figure out what the rest of the path is 131 # figure out what the rest of the path is
120 if len(l_path) > 2: 132 if len(l_path) > 2:
121 rest = '/'.join(l_path[2:]) 133 rest = '/'.join(l_path[2:])
122 else: 134 else:
268 if __name__ == '__main__': 280 if __name__ == '__main__':
269 main() 281 main()
270 282
271 # 283 #
272 # $Log: not supported by cvs2svn $ 284 # $Log: not supported by cvs2svn $
285 # Revision 1.11 2001/08/07 00:24:42 richard
286 # stupid typo
287 #
273 # Revision 1.10 2001/08/07 00:15:51 richard 288 # Revision 1.10 2001/08/07 00:15:51 richard
274 # Added the copyright/license notice to (nearly) all files at request of 289 # Added the copyright/license notice to (nearly) all files at request of
275 # Bizar Software. 290 # Bizar Software.
276 # 291 #
277 # Revision 1.9 2001/08/05 07:44:36 richard 292 # Revision 1.9 2001/08/05 07:44:36 richard

Roundup Issue Tracker: http://roundup-tracker.org/