diff --git a/roundup-server b/roundup-server
index ff4e0c146a7a18a45489577362c30a9b6e69e1fe..d6a03e0eb0eeeb9807cf4a5ad4b9fa3a3f12d98b 100755 (executable)
--- a/roundup-server
+++ b/roundup-server
Stolen from CGIHTTPServer
-$Id: roundup-server,v 1.1 2001-07-23 03:46:48 richard Exp $
+$Id: roundup-server,v 1.5 2001-07-24 01:07:59 richard Exp $
"""
import sys
if int(sys.version[0]) < 2:
print "Content-Type: text/plain\n"
print "Roundup requires Python 2.0 or newer."
+ sys.exit(0)
__version__ = "0.1"
__all__ = ["RoundupRequestHandler"]
-import os, urllib, StringIO, traceback, cgi, binascii, string
+import os, urllib, StringIO, traceback, cgi, binascii, string, getopt
import BaseHTTPServer
import SimpleHTTPServer
# Roundup modules of use here
from roundup import cgitb, cgi_client
-# These are here temporarily until I get a real reload system in place
-from roundup import date, hyperdb, hyper_bsddb, roundupdb, htmltemplate
-
#
## Configuration
#
# This indicates where the Roundup instance lives
-ROUNDUPS = {
- 'test': '/tmp/roundup_test',
+ROUNDUP_INSTANCE_HOMES = {
+ 'bar': '/tmp/bar',
}
# Where to log debugging information to. Use an instance of DevNull if you
class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+ ROUNDUP_INSTANCE_HOMES = ROUNDUP_INSTANCE_HOMES
def send_head(self):
"""Version of send_head that support CGI scripts"""
# TODO: actually do the HEAD ...
raise ValueError, 'No instance specified'
l_path = string.split(rest, '/')
instance = urllib.unquote(l_path[1])
- if ROUNDUPS.has_key(instance):
- instance_home = ROUNDUPS[instance]
+ if self.ROUNDUP_INSTANCE_HOMES.has_key(instance):
+ instance_home = self.ROUNDUP_INSTANCE_HOMES[instance]
module_path, instance = os.path.split(instance_home)
sys.path.insert(0, module_path)
try:
# reload all modules
# TODO check for file timestamp changes and dependencies
- reload(date)
- reload(hyperdb)
- reload(roundupdb)
- reload(htmltemplate)
- reload(cgi_client)
- sys.path.insert(0, module_path)
- try:
- reload(instance)
- finally:
- del sys.path[0]
+ #reload(date)
+ #reload(hyperdb)
+ #reload(roundupdb)
+ #reload(htmltemplate)
+ #reload(cgi_client)
+ #sys.path.insert(0, module_path)
+ #try:
+ # reload(instance)
+ #finally:
+ # del sys.path[0]
# initialise the roundupdb, check for auth
db = instance.open('admin')
nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
return nobody
-if __name__ == '__main__':
- # TODO make this configurable again? command-line seems ok to me...
- address = ('', 8080)
+def usage(message=''):
+ if message: message = 'Error: %s\n'%message
+ print '''%sUsage:
+roundup-server [-n hostname] [-p port] [name=instance home]*
+
+ -n: sets the host name
+ -p: sets the port to listen on
+
+ name=instance home
+ Sets the instance home(s) to use. The name is how the instance is
+ identified in the URL (it's the first part of the URL path). The
+ instance home is the directory that was identified when you did
+ "roundup-admin init". You may specify any number of these name=home
+ pairs on the command-line. For convenience, you may edit the
+ ROUNDUP_INSTANCE_HOMES variable in the roundup-server file instead.
+'''%message
+ sys.exit(0)
+
+def main():
+ hostname = ''
+ port = 8080
+ try:
+ # handle the command-line args
+ optlist, args = getopt.getopt(sys.argv[1:], 'n:p:')
+ for (opt, arg) in optlist:
+ if opt == '-n': hostname = arg
+ elif opt == '-p': port = int(arg)
+ elif opt == '-h': usage()
+
+ # handle instance specs
+ if args:
+ d = {}
+ for arg in args:
+ name, home = string.split(arg, '=')
+ d[name] = home
+ RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d
+ except:
+ type, value = sys.exc_info()[:2]
+ usage('%s: %s'%(type, value))
+
+ # we don't want the cgi module interpreting the command-line args ;)
+ sys.argv = sys.argv[:1]
+ address = (hostname, port)
httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler)
print 'Roundup server started on', address
httpd.serve_forever()
+if __name__ == '__main__':
+ main()
+
#
# $Log: not supported by cvs2svn $
+# Revision 1.4 2001/07/23 10:31:45 richard
+# disabled the reloading until it can be done properly
+#
+# Revision 1.3 2001/07/23 08:53:44 richard
+# Fixed the ROUNDUPS decl in roundup-server
+# Move the installation notes to INSTALL
+#
+# Revision 1.2 2001/07/23 04:05:05 anthonybaxter
+# actually quit if python version wrong
+#
+# Revision 1.1 2001/07/23 03:46:48 richard
+# moving the bin files to facilitate out-of-the-boxness
+#
# Revision 1.1 2001/07/22 11:15:45 richard
# More Grande Splite stuff
#