X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=cgi-bin%2Froundup.cgi;h=ad92274b4a170903e0d88b95d689e7f65d296748;hb=0fb16b927f803df0e6be67702ffd69e89bcc769f;hp=c8b1030b823c464a0730f3de8099c52c3d4ebf87;hpb=e6c4c7f8d5631098772610818c9907b51081dac2;p=roundup.git diff --git a/cgi-bin/roundup.cgi b/cgi-bin/roundup.cgi index c8b1030..ad92274 100755 --- a/cgi-bin/roundup.cgi +++ b/cgi-bin/roundup.cgi @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundup.cgi,v 1.15 2001-10-29 23:55:44 richard Exp $ +# $Id: roundup.cgi,v 1.16 2001-11-01 22:04:37 richard Exp $ # python version check import sys @@ -59,6 +59,18 @@ except: traceback.print_exc(None, s) print cgi.escape(s.getvalue()), "" +class RequestWrapper: + '''Used to make the CGI server look like a BaseHTTPRequestHandler + ''' + def __init__(self, wfile): + self.wfile = wfile + def send_response(self, code): + self.wfile.write('Status: %s\r\n'%code) + def send_header(self, keyword, value): + self.wfile.write("%s: %s\r\n" % (keyword, value)) + def end_headers(self, keyword, value): + self.wfile.write("\r\n") + def main(out, err): import os, string import roundup.instance @@ -66,26 +78,30 @@ def main(out, err): instance = path[1] os.environ['INSTANCE_NAME'] = instance os.environ['PATH_INFO'] = string.join(path[2:], '/') + request = RequestWrapper(out) if ROUNDUP_INSTANCE_HOMES.has_key(instance): instance_home = ROUNDUP_INSTANCE_HOMES[instance] instance = roundup.instance.open(instance_home) from roundup import cgi_client - client = instance.Client(instance, out, os.environ) + client = instance.Client(instance, request, os.environ) try: client.main() except cgi_client.Unauthorised: - out.write('Content-Type: text/html\n') - out.write('Status: 403\n\n') + request.send_response(403) + request.send_header('Content-Type', 'text/html') + request.end_headers() out.write('Unauthorised') except cgi_client.NotFound: - out.write('Content-Type: text/html\n') - out.write('Status: 404\n\n') + request.send_response(404) + request.send_header('Content-Type', 'text/html') + request.end_headers() out.write('Not found: %s'%client.path) else: import urllib - w = out.write - w("Content-Type: text/html\n\n") - w('Roundup instances index\n') + request.send_response(200) + request.send_header('Content-Type', 'text/html') + w = request.wfile.write + w('Roundup instances index\n') w('

Roundup instances index

    \n') for instance in ROUNDUP_INSTANCE_HOMES.keys(): w('
  1. %s\n'%( @@ -111,6 +127,9 @@ sys.stdout, sys.stderr = out, err # # $Log: not supported by cvs2svn $ +# Revision 1.15 2001/10/29 23:55:44 richard +# Fix to CGI top-level index (thanks Juergen Hermann) +# # Revision 1.14 2001/10/27 00:22:35 richard # Fixed some URL issues in roundup.cgi, again thanks Juergen Hermann. #