Mercurial > p > roundup > code
comparison roundup/scripts/roundup_server.py @ 992:6003d6fa02a5
new CGI frontend support
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 30 Aug 2002 08:37:00 +0000 |
| parents | cdcee6721841 |
| children | 1890c611de08 |
comparison
equal
deleted
inserted
replaced
| 991:79129f013153 | 992:6003d6fa02a5 |
|---|---|
| 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 16 # | 16 # |
| 17 """ HTTP Server that serves roundup. | 17 """ HTTP Server that serves roundup. |
| 18 | 18 |
| 19 $Id: roundup_server.py,v 1.5 2002-03-14 23:59:24 richard Exp $ | 19 $Id: roundup_server.py,v 1.6 2002-08-30 08:33:28 richard Exp $ |
| 20 """ | 20 """ |
| 21 | 21 |
| 22 # python version check | 22 # python version check |
| 23 from roundup import version_check | 23 from roundup import version_check |
| 24 | 24 |
| 25 import sys, os, urllib, StringIO, traceback, cgi, binascii, getopt, imp | 25 import sys, os, urllib, StringIO, traceback, cgi, binascii, getopt, imp |
| 26 import BaseHTTPServer | 26 import BaseHTTPServer |
| 27 | 27 |
| 28 # Roundup modules of use here | 28 # Roundup modules of use here |
| 29 from roundup import cgitb, cgi_client | 29 from roundup.cgi import cgitb, client |
| 30 import roundup.instance | 30 import roundup.instance |
| 31 from roundup.i18n import _ | 31 from roundup.i18n import _ |
| 32 | 32 |
| 33 # | 33 # |
| 34 ## Configuration | 34 ## Configuration |
| 66 """ | 66 """ |
| 67 save_stdin = sys.stdin | 67 save_stdin = sys.stdin |
| 68 sys.stdin = self.rfile | 68 sys.stdin = self.rfile |
| 69 try: | 69 try: |
| 70 self.inner_run_cgi() | 70 self.inner_run_cgi() |
| 71 except cgi_client.NotFound: | 71 except client.NotFound: |
| 72 self.send_error(404, self.path) | 72 self.send_error(404, self.path) |
| 73 except cgi_client.Unauthorised: | 73 except client.Unauthorised: |
| 74 self.send_error(403, self.path) | 74 self.send_error(403, self.path) |
| 75 except: | 75 except: |
| 76 # it'd be nice to be able to detect if these are going to have | 76 # it'd be nice to be able to detect if these are going to have |
| 77 # any effect... | 77 # any effect... |
| 78 self.send_response(400) | 78 self.send_response(400) |
| 125 instance_name = urllib.unquote(l_path[1]) | 125 instance_name = urllib.unquote(l_path[1]) |
| 126 if self.ROUNDUP_INSTANCE_HOMES.has_key(instance_name): | 126 if self.ROUNDUP_INSTANCE_HOMES.has_key(instance_name): |
| 127 instance_home = self.ROUNDUP_INSTANCE_HOMES[instance_name] | 127 instance_home = self.ROUNDUP_INSTANCE_HOMES[instance_name] |
| 128 instance = roundup.instance.open(instance_home) | 128 instance = roundup.instance.open(instance_home) |
| 129 else: | 129 else: |
| 130 raise cgi_client.NotFound | 130 raise client.NotFound |
| 131 | 131 |
| 132 # figure out what the rest of the path is | 132 # figure out what the rest of the path is |
| 133 if len(l_path) > 2: | 133 if len(l_path) > 2: |
| 134 rest = '/'.join(l_path[2:]) | 134 rest = '/'.join(l_path[2:]) |
| 135 else: | 135 else: |
| 159 env['HTTP_HOST'] = self.headers['host'] | 159 env['HTTP_HOST'] = self.headers['host'] |
| 160 | 160 |
| 161 decoded_query = query.replace('+', ' ') | 161 decoded_query = query.replace('+', ' ') |
| 162 | 162 |
| 163 # do the roundup thang | 163 # do the roundup thang |
| 164 client = instance.Client(instance, self, env) | 164 c = instance.Client(instance, self, env) |
| 165 client.main() | 165 c.main() |
| 166 | 166 |
| 167 def usage(message=''): | 167 def usage(message=''): |
| 168 if message: | 168 if message: |
| 169 message = _('Error: %(error)s\n\n')%{'error': message} | 169 message = _('Error: %(error)s\n\n')%{'error': message} |
| 170 print _('''%(message)sUsage: | 170 print _('''%(message)sUsage: |
| 245 if __name__ == '__main__': | 245 if __name__ == '__main__': |
| 246 run() | 246 run() |
| 247 | 247 |
| 248 # | 248 # |
| 249 # $Log: not supported by cvs2svn $ | 249 # $Log: not supported by cvs2svn $ |
| 250 # Revision 1.5 2002/03/14 23:59:24 richard | |
| 251 # . #517734 ] web header customisation is obscure | |
| 252 # | |
| 250 # Revision 1.4 2002/02/21 07:02:54 richard | 253 # Revision 1.4 2002/02/21 07:02:54 richard |
| 251 # The correct var is "HTTP_HOST" | 254 # The correct var is "HTTP_HOST" |
| 252 # | 255 # |
| 253 # Revision 1.3 2002/02/21 06:57:39 richard | 256 # Revision 1.3 2002/02/21 06:57:39 richard |
| 254 # . Added popup help for classes using the classhelp html template function. | 257 # . Added popup help for classes using the classhelp html template function. |
