annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
1 #!/usr/bin/python
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
2 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
3 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
4 # This module is free software, and you may redistribute it and/or modify
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
5 # under the same terms as Python, so long as this copyright message and
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
6 # disclaimer are retained in their original form.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
7 #
214
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
8 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
9 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
10 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
11 # POSSIBILITY OF SUCH DAMAGE.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
12 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
13 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
18 #
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
19 """ HTTP Server that serves roundup.
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
20
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
21 Based on CGIHTTPServer in the Python library.
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
22
252
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
23 $Id: roundup-server,v 1.12 2001-09-29 13:27:00 richard Exp $
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
24
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
25 """
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
26 import sys
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
27 if int(sys.version[0]) < 2:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
28 print "Content-Type: text/plain\n"
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
29 print "Roundup requires Python 2.0 or newer."
32
b475e7d3ce52 actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents: 27
diff changeset
30 sys.exit(0)
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
31
190
996eaf90c01e Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
32 import os, urllib, StringIO, traceback, cgi, binascii, string, getopt, imp
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
33 import BaseHTTPServer
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
34 import SimpleHTTPServer
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
35
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
36 # Roundup modules of use here
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
37 from roundup import cgitb, cgi_client
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents: 193
diff changeset
38 import roundup.instance
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
39
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
40 #
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
41 ## Configuration
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
42 #
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
43
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
44 # This indicates where the Roundup instance lives
52
33bfce110d1e Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents: 32
diff changeset
45 ROUNDUP_INSTANCE_HOMES = {
54
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
46 'bar': '/tmp/bar',
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
47 }
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
48
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
49 # Where to log debugging information to. Use an instance of DevNull if you
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
50 # don't want to log anywhere.
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
51 # TODO: actually use this stuff
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
52 #class DevNull:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
53 # def write(self, info):
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
54 # pass
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
55 #LOG = open('/var/log/roundup.cgi.log', 'a')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
56 #LOG = DevNull()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
57
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
58 #
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
59 ## end configuration
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
60 #
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
61
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
62
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
63 class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
61
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
64 ROUNDUP_INSTANCE_HOMES = ROUNDUP_INSTANCE_HOMES
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
65 def send_head(self):
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
66 """Version of send_head that support CGI scripts"""
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
67 # TODO: actually do the HEAD ...
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
68 return self.run_cgi()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
69
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
70 def run_cgi(self):
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
71 """ Execute the CGI command. Wrap an innner call in an error
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
72 handler so all errors can be caught.
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
73 """
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
74 save_stdin = sys.stdin
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
75 sys.stdin = self.rfile
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
76 try:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
77 self.inner_run_cgi()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
78 except cgi_client.Unauthorised:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
79 self.wfile.write('Content-Type: text/html\n')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
80 self.wfile.write('Status: 403\n')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
81 self.wfile.write('Unauthorised')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
82 except:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
83 try:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
84 reload(cgitb)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
85 self.wfile.write("Content-Type: text/html\n\n")
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
86 self.wfile.write(cgitb.breaker())
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
87 self.wfile.write(cgitb.html())
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
88 except:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
89 self.wfile.write("Content-Type: text/html\n\n")
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
90 self.wfile.write("<pre>")
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
91 s = StringIO.StringIO()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
92 traceback.print_exc(None, s)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
93 self.wfile.write(cgi.escape(s.getvalue()))
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
94 self.wfile.write("</pre>\n")
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
95 sys.stdin = save_stdin
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
96
252
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
97 def index(self):
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
98 ''' Print up an index of the available instances
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
99 '''
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
100 w = self.wfile.write
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
101 w("Content-Type: text/html\n\n")
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
102 w('<html><head><title>Roundup instances index</title><head>\n')
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
103 w('<body><h1>Roundup instances index</h1><ol>\n')
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
104 for instance in self.ROUNDUP_INSTANCE_HOMES.keys():
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
105 w('<li><a href="%s/index">%s</a>\n'%(urllib.quote(instance),
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
106 instance))
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
107 w('</ol></body></html>')
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
108
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
109 def inner_run_cgi(self):
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
110 ''' This is the inner part of the CGI handling
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
111 '''
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
112
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
113 rest = self.path
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
114 i = rest.rfind('?')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
115 if i >= 0:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
116 rest, query = rest[:i], rest[i+1:]
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
117 else:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
118 query = ''
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
119
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
120 # figure the instance
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
121 if rest == '/':
252
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
122 return self.index()
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
123 l_path = string.split(rest, '/')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
124 instance = urllib.unquote(l_path[1])
61
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
125 if self.ROUNDUP_INSTANCE_HOMES.has_key(instance):
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
126 instance_home = self.ROUNDUP_INSTANCE_HOMES[instance]
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents: 193
diff changeset
127 instance = roundup.instance.open(instance_home)
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
128 else:
252
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
129 return self.index()
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
130
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
131 # figure out what the rest of the path is
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
132 if len(l_path) > 2:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
133 rest = '/'.join(l_path[2:])
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
134 else:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
135 rest = '/'
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
136
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
137 # Set up the CGI environment
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
138 env = {}
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
139 env['REQUEST_METHOD'] = self.command
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
140 env['PATH_INFO'] = urllib.unquote(rest)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
141 if query:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
142 env['QUERY_STRING'] = query
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
143 host = self.address_string()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
144 if self.headers.typeheader is None:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
145 env['CONTENT_TYPE'] = self.headers.type
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
146 else:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
147 env['CONTENT_TYPE'] = self.headers.typeheader
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
148 length = self.headers.getheader('content-length')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
149 if length:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
150 env['CONTENT_LENGTH'] = length
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
151 co = filter(None, self.headers.getheaders('cookie'))
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
152 if co:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
153 env['HTTP_COOKIE'] = ', '.join(co)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
154 env['SCRIPT_NAME'] = ''
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
155 env['SERVER_NAME'] = self.server.server_name
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
156 env['SERVER_PORT'] = str(self.server.server_port)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
157
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
158 decoded_query = query.replace('+', ' ')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
159
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
160 # if root, setuid to nobody
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
161 # TODO why isn't this done much earlier? - say, in main()?
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
162 if not os.getuid():
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
163 nobody = nobody_uid()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
164 os.setuid(nobody)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
165
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
166 # reload all modules
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
167 # TODO check for file timestamp changes and dependencies
54
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
168 #reload(date)
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
169 #reload(hyperdb)
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
170 #reload(roundupdb)
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
171 #reload(htmltemplate)
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
172 #reload(cgi_client)
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
173 #sys.path.insert(0, module_path)
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
174 #try:
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
175 # reload(instance)
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
176 #finally:
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
177 # del sys.path[0]
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
178
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
179 # initialise the roundupdb, check for auth
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
180 db = instance.open('admin')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
181 message = 'Unauthorised'
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
182 auth = self.headers.getheader('authorization')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
183 if auth:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
184 l = binascii.a2b_base64(auth.split(' ')[1]).split(':')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
185 user = l[0]
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
186 password = None
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
187 if len(l) > 1:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
188 password = l[1]
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
189 try:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
190 uid = db.user.lookup(user)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
191 except KeyError:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
192 auth = None
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
193 message = 'Username not recognised'
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
194 else:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
195 if password != db.user.get(uid, 'password'):
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
196 message = 'Incorrect password'
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
197 auth = None
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
198 db.close()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
199 del db
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
200 if not auth:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
201 self.send_response(401)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
202 self.send_header('Content-Type', 'text/html')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
203 self.send_header('WWW-Authenticate', 'basic realm="Roundup"')
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
204 self.end_headers()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
205 self.wfile.write(message)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
206 return
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
207
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
208 self.send_response(200, "Script output follows")
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
209
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
210 # do the roundup thang
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
211 db = instance.open(user)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
212 client = instance.Client(self.wfile, db, env, user)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
213 client.main()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
214 do_POST = run_cgi
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
215
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
216 nobody = None
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
217
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
218 def nobody_uid():
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
219 """Internal routine to get nobody's uid"""
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
220 global nobody
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
221 if nobody:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
222 return nobody
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
223 try:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
224 import pwd
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
225 except ImportError:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
226 return -1
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
227 try:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
228 nobody = pwd.getpwnam('nobody')[2]
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
229 except KeyError:
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
230 nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
231 return nobody
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
232
61
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
233 def usage(message=''):
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
234 if message: message = 'Error: %s\n'%message
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
235 print '''%sUsage:
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
236 roundup-server [-n hostname] [-p port] [name=instance home]*
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
237
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
238 -n: sets the host name
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
239 -p: sets the port to listen on
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
240
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
241 name=instance home
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
242 Sets the instance home(s) to use. The name is how the instance is
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
243 identified in the URL (it's the first part of the URL path). The
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
244 instance home is the directory that was identified when you did
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
245 "roundup-admin init". You may specify any number of these name=home
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
246 pairs on the command-line. For convenience, you may edit the
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
247 ROUNDUP_INSTANCE_HOMES variable in the roundup-server file instead.
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
248 '''%message
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
249 sys.exit(0)
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
250
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
251 def main():
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
252 hostname = ''
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
253 port = 8080
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
254 try:
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
255 # handle the command-line args
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
256 optlist, args = getopt.getopt(sys.argv[1:], 'n:p:')
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
257 for (opt, arg) in optlist:
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
258 if opt == '-n': hostname = arg
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
259 elif opt == '-p': port = int(arg)
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
260 elif opt == '-h': usage()
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
261
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
262 # handle instance specs
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
263 if args:
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
264 d = {}
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
265 for arg in args:
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
266 name, home = string.split(arg, '=')
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
267 d[name] = home
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
268 RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
269 except:
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
270 type, value = sys.exc_info()[:2]
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
271 usage('%s: %s'%(type, value))
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
272
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
273 # we don't want the cgi module interpreting the command-line args ;)
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
274 sys.argv = sys.argv[:1]
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
275 address = (hostname, port)
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
276 httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler)
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
277 print 'Roundup server started on', address
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
278 httpd.serve_forever()
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
279
61
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
280 if __name__ == '__main__':
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
281 main()
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
282
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
283 #
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
284 # $Log: not supported by cvs2svn $
252
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
285 # Revision 1.11 2001/08/07 00:24:42 richard
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
286 # stupid typo
76c6994aa4e8 CGI interfaces now spit up a top-level index of all instances they can serve.
Richard Jones <richard@users.sourceforge.net>
parents: 214
diff changeset
287 #
214
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
288 # Revision 1.10 2001/08/07 00:15:51 richard
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
289 # Added the copyright/license notice to (nearly) all files at request of
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
290 # Bizar Software.
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
291 #
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
292 # Revision 1.9 2001/08/05 07:44:36 richard
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
293 # Instances are now opened by a special function that generates a unique
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
294 # module name for the instances on import time.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 204
diff changeset
295 #
204
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents: 193
diff changeset
296 # Revision 1.8 2001/08/03 01:28:33 richard
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents: 193
diff changeset
297 # Used the much nicer load_package, pointed out by Steve Majewski.
c1461733cbf9 Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents: 193
diff changeset
298 #
193
241a0323aacb Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents: 190
diff changeset
299 # Revision 1.7 2001/08/03 00:59:34 richard
241a0323aacb Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents: 190
diff changeset
300 # Instance import now imports the instance using imp.load_module so that
241a0323aacb Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents: 190
diff changeset
301 # we can have instance homes of "roundup" or other existing python package
241a0323aacb Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents: 190
diff changeset
302 # names.
241a0323aacb Used the much nicer load_package, pointed out by Steve Majewski.
Richard Jones <richard@users.sourceforge.net>
parents: 190
diff changeset
303 #
190
996eaf90c01e Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
304 # Revision 1.6 2001/07/29 07:01:39 richard
996eaf90c01e Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
305 # Added vim command to all source so that we don't get no steenkin' tabs :)
996eaf90c01e Instance import now imports the instance using imp.load_module...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
306 #
127
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 61
diff changeset
307 # Revision 1.5 2001/07/24 01:07:59 richard
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 61
diff changeset
308 # Added command-line arg handling to roundup-server so it's more useful
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 61
diff changeset
309 # out-of-the-box.
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 61
diff changeset
310 #
61
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
311 # Revision 1.4 2001/07/23 10:31:45 richard
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
312 # disabled the reloading until it can be done properly
820c8bb1b71a Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents: 54
diff changeset
313 #
54
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
314 # Revision 1.3 2001/07/23 08:53:44 richard
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
315 # Fixed the ROUNDUPS decl in roundup-server
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
316 # Move the installation notes to INSTALL
b68bcb176d1a disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents: 52
diff changeset
317 #
52
33bfce110d1e Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents: 32
diff changeset
318 # Revision 1.2 2001/07/23 04:05:05 anthonybaxter
33bfce110d1e Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents: 32
diff changeset
319 # actually quit if python version wrong
33bfce110d1e Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents: 32
diff changeset
320 #
32
b475e7d3ce52 actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents: 27
diff changeset
321 # Revision 1.1 2001/07/23 03:46:48 richard
b475e7d3ce52 actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents: 27
diff changeset
322 # moving the bin files to facilitate out-of-the-boxness
b475e7d3ce52 actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents: 27
diff changeset
323 #
27
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
324 # Revision 1.1 2001/07/22 11:15:45 richard
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
325 # More Grande Splite stuff
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
326 #
e5e9ea306a09 moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
327 #
127
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 61
diff changeset
328 # vim: set filetype=python ts=4 sw=4 et si

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