Here is a generic script that can be used to serve any Quixote project as an HTTP or SCGI process. I’ve found it quite useful when developing multiple Quixote2-based sites because I don’t have to worry about a custom launcher. This script will continue to live on at the official quixote wiki page.
#!/usr/bin/python
from quixote2.publish import Publisher
from optparse import OptionParser
SCGI_PORT = 2974
HTTP_PORT = 8080
def main ():
parser = OptionParser(usage="usage: %prog [options] QuixoteDirectory")
parser.set_description('Publishes the Quixote Directory object at the specified ip and port.')
parser.add_option('--standalone', dest="standalone",
default=False, action='store_true',
help="Run as a stand alone http server (useful for development)")
parser.add_option('--ip', dest="host",
default='localhost', type="str",
help="IP address to listen on")
parser.add_option('--port', dest="port",
default=SCGI_PORT, type="int",
help="Port to listen on")
(options, args) = parser.parse_args()
dirname = args[0]
i = dirname.rfind('.')
modname = dirname[:i]
clsname = dirname[i+1:]
m = __import__(modname, globals(), locals(), [clsname])
RootDirectory = getattr(m, clsname)
def create_publisher():
return Publisher(RootDirectory(), display_exceptions='plain')
if options.standalone:
from quixote2.server.simple_server import run
run(create_publisher, host=options.host, port=options.port)
else:
from quixote2.server.scgi_server import run
run(create_publisher, host=options.host, port=options.port, script_name='')
if __name__ == '__main__':
main()