Mercurial > p > roundup > code
comparison cgi-bin/roundup.cgi @ 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 | 96fa4c11d3b0 |
comparison
equal
deleted
inserted
replaced
| 251:2f4123c715f1 | 252:76c6994aa4e8 |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 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 $ |
| 20 | 20 |
| 21 # python version check | 21 # python version check |
| 22 import sys | 22 import sys |
| 23 if int(sys.version[0]) < 2: | 23 if int(sys.version[0]) < 2: |
| 24 print "Content-Type: text/plain\n" | 24 print "Content-Type: text/plain\n" |
| 95 except cgi_client.Unauthorised: | 95 except cgi_client.Unauthorised: |
| 96 out.write('Content-Type: text/html\n') | 96 out.write('Content-Type: text/html\n') |
| 97 out.write('Status: 403\n\n') | 97 out.write('Status: 403\n\n') |
| 98 out.write('Unauthorised') | 98 out.write('Unauthorised') |
| 99 | 99 |
| 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 | |
| 100 # | 112 # |
| 101 # Now do the actual CGI handling | 113 # Now do the actual CGI handling |
| 102 # | 114 # |
| 103 out, err = sys.stdout, sys.stderr | 115 out, err = sys.stdout, sys.stderr |
| 104 try: | 116 try: |
| 109 instance = path[1] | 121 instance = path[1] |
| 110 os.environ['PATH_INFO'] = string.join(path[2:], '/') | 122 os.environ['PATH_INFO'] = string.join(path[2:], '/') |
| 111 if ROUNDUP_INSTANCE_HOMES.has_key(instance): | 123 if ROUNDUP_INSTANCE_HOMES.has_key(instance): |
| 112 instance_home = ROUNDUP_INSTANCE_HOMES[instance] | 124 instance_home = ROUNDUP_INSTANCE_HOMES[instance] |
| 113 instance = roundup.instance.open(instance_home) | 125 instance = roundup.instance.open(instance_home) |
| 126 main(instance, out) | |
| 114 else: | 127 else: |
| 115 raise ValueError, 'No such instance "%s"'%instance | 128 index() |
| 116 main(instance, out) | |
| 117 except: | 129 except: |
| 118 sys.stdout, sys.stderr = out, err | 130 sys.stdout, sys.stderr = out, err |
| 119 out.write('Content-Type: text/html\n\n') | 131 out.write('Content-Type: text/html\n\n') |
| 120 cgitb.handler() | 132 cgitb.handler() |
| 121 sys.stdout.flush() | 133 sys.stdout.flush() |
| 122 sys.stdout, sys.stderr = out, err | 134 sys.stdout, sys.stderr = out, err |
| 123 | 135 |
| 124 # | 136 # |
| 125 # $Log: not supported by cvs2svn $ | 137 # $Log: not supported by cvs2svn $ |
| 138 # Revision 1.10 2001/08/07 00:24:42 richard | |
| 139 # stupid typo | |
| 140 # | |
| 126 # Revision 1.9 2001/08/07 00:15:51 richard | 141 # Revision 1.9 2001/08/07 00:15:51 richard |
| 127 # Added the copyright/license notice to (nearly) all files at request of | 142 # Added the copyright/license notice to (nearly) all files at request of |
| 128 # Bizar Software. | 143 # Bizar Software. |
| 129 # | 144 # |
| 130 # Revision 1.8 2001/08/05 07:43:52 richard | 145 # Revision 1.8 2001/08/05 07:43:52 richard |
