durusmail: quixote-users: Lucio's Server
Lucio's Server
2003-05-23
2003-05-23
Lucio's Server
Mark Bucciarelli
2003-05-23
Would the maintainer's consider including the attached class (or some
variant thereof) in 0.7?

Basically, it is Lucio's server with the following changes (full diff
below):

(1) defaults namespace to quixote.demo
(2) uses Publisher instead of SessionPublisher.

A new user/developer can simply type ./server.py, point their browser
to localhost:8000 and up pops the demo.

Lucio--do you like the license text?  :-)

--- server.orig.py      2003-05-23 13:26:50.000000000 -0400
+++ server.py   2003-05-23 13:25:48.000000000 -0400
@@ -1,8 +1,11 @@
 #!/usr/bin/env python
 """
+    Taken from public domain.
+    Author: Lucio 
+    License: "Use it freely, get rich, whatever."
+    ref: Quixote-users list, 5/22/03
 """

-
 __version__ = "0.4"

 __all__ = ["QuizoteHTTPRequestHandler"]
@@ -16,9 +19,8 @@
 from StringIO import StringIO

 from quixote import enable_ptl, Publisher
-from quixote.publish import SessionPublisher
-from quixote.session import SessionManager
-
+#from quixote.publish import SessionPublisher
+#from quixote.session import SessionManager


 class CGIParser:
@@ -39,6 +41,7 @@
             self.outfile.write(rest)
             self.write = self.outfile.write

+
 class
QuixoteHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):

     root = '/'
@@ -58,7 +61,8 @@

     def run_quixote(self):
         l = len(self.root)
-        scheme, location, path, parameters, query, fragment =
urlparse.urlparse(self.path)
+        scheme, location, path, parameters, \
+                query, fragment = urlparse.urlparse(self.path)
         # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
         # XXX Much of the following could be prepared ahead of time!
         env = {}
@@ -81,6 +85,7 @@
         # XXX AUTH_TYPE
         # XXX REMOTE_USER
         # XXX REMOTE_IDENT
+
         if self.headers.typeheader is None:
             env['CONTENT_TYPE'] = self.headers.type
         else:
@@ -105,16 +110,18 @@
         p = CGIParser(self, self.wfile)
         self.publisher.publish(self.rfile, p, p, env)

+
 class QuixoteHTTPServer(BaseHTTPServer.HTTPServer):
     def __init__(self, saddr, handler, namespace, conf = None):
         BaseHTTPServer.HTTPServer.__init__(self, saddr, handler)
         self.root_namespace = namespace
         enable_ptl()
-        from web.session import PlySession
-        smg = SessionManager(session_class=PlySession)
-        self.publisher = SessionPublisher(self.root_namespace,
session_mgr=smg)
-        if conf:
-            self.publisher.read_config(conf)
+        #from web.session import PlySession
+        #smg = SessionManager(session_class=PlySession)
+        #self.publisher = SessionPublisher(self.root_namespace,
session_mgr=smg)
+        #if conf:
+        #    self.publisher.read_config(conf)
+        self.publisher = Publisher(self.root_namespace, conf)
         self.publisher.setup_logs()

     def finish_request(self, request, client_address):
@@ -124,9 +131,6 @@
         self.RequestHandlerClass(request, client_address, self,
self.publisher)


-
-
-
 def usage():
     print sys.argv[0],": [-f config_file] [-p port] namespace"
     print "Defaults: port = 8000, config_file = None"
@@ -135,9 +139,9 @@
     import getopt
     optlist, args = getopt.getopt(sys.argv[1:], "p:f:")
     if len(args) != 1:
-        usage()
-        return
-    namespace = args[0]
+        namespace = 'quixote.demo'
+    else:
+        namespace = args[0]

     conf = None
     port = 8000
@@ -164,3 +168,4 @@

 if __name__ == '__main__':
     Run_Quixote()
+
reply