[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server - HTTPServer.py:1.1.2.8

Tres Seaver tseaver@zope.com
Thu, 22 Nov 2001 00:42:06 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server
In directory cvs.zope.org:/tmp/cvs-serv3409/lib/python/Zope/Server

Modified Files:
      Tag: Zope-3x-branch
	HTTPServer.py 
Log Message:
 - Add unit tests for parts of Zope.Server.HTTPServer.

=== Zope3/lib/python/Zope/Server/HTTPServer.py 1.1.2.7 => 1.1.2.8 ===
 import time
 import socket
+
+from asyncore import dispatcher, socket_map
 from cStringIO import StringIO
 
 from PubCore import handle
 from HTTPResponse import make_response
-from Zope.Publisher.HTTP.HTTPRequest import HTTPRequest
 
-from medusa.http_server import http_server,get_header, http_channel, VERSION_STRING
-import asyncore
-from medusa import counter, producers
-from medusa.test import  max_sockets
+from medusa import counter, producers#, logger
 from medusa.default_handler import unquote
-from asyncore import compact_traceback, dispatcher
+from medusa.http_server import http_server, http_channel, get_header
 
+from Zope.Publisher.HTTP.HTTPRequest import HTTPRequest
 from Zope.Server import CONNECTION_LIMIT
 from Zope.Server import requestCloseOnExec
-from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
-#import DebugLogger
-from medusa import logger
 
-register_subsystem('Zope.Server.HTTPServer')
+#from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
+#register_subsystem('Zope.Server.HTTPServer')
 
 CONTENT_LENGTH  = re.compile('Content-Length: ([0-9]+)',re.I)
 CONNECTION      = re.compile('Connection: (.*)', re.I)
@@ -106,7 +103,7 @@
         request_payload -- an implementation of IRequestPayload
         response_payload -- an implementation of IResponsePayload
         uri_base -- string, the base uri of the published module
-                    defaults to '/<module name>' if not given.
+                    defaults to '/' if not given.
         env -- dictionary, environment variables to be overridden.        
                     Replaces standard variables with supplied ones.
         """
@@ -118,9 +115,7 @@
         # if uri_base is unspecified, assume it
         # starts with the published module name
         #
-        if uri_base is None:
-            uri_base='/%s' % module
-        elif uri_base == '':
+        if not uri_base:
             uri_base='/'
         else:
             if uri_base[0] != '/':
@@ -222,11 +217,11 @@
     def continue_request(self, sin, request):
         "continue handling request now that we have the stdin"
        
-        s=get_header(CONTENT_LENGTH, request.header)
-        if s:
-            s=int(s)
-        else:
-            s=0    
+        #s=get_header(CONTENT_LENGTH, request.header)
+        #if s:
+            #s=int(s)
+        #else:
+            #s=0    
         #DebugLogger.log('I', id(request), s)
 
         env=self.get_environment(request)
@@ -300,7 +295,7 @@
 
     def kill_zombies(self):
         now = int (time.time())
-        for channel in asyncore.socket_map.values():
+        for channel in socket_map.values():
             if channel.__class__ == self.__class__:
                 if (now - channel.creation_time) > channel.zombie_timeout:
                     channel.close()
@@ -315,9 +310,11 @@
     shutup=0
 
     def __init__ (self, ip, port, resolver=None, logger_object=None):
-        self.shutup=1
+
+        self.shutup = 1
         http_server.__init__(self, ip, port, resolver, logger_object)
         self.shutup=0
+
         self.log_info('HTTP server started at %s\n'
                       '\tHostname: %s\n\tPort: %d' % (
 			time.ctime(time.time()),
@@ -335,7 +332,7 @@
 
     def readable(self):
         return self.accepting and \
-                len(asyncore.socket_map) < CONNECTION_LIMIT
+                len(socket_map) < CONNECTION_LIMIT
 
     def listen(self, num):
         # override asyncore limits for nt's listen queue size