[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server - HTTPServer.py:1.1.2.9 PublisherServers.py:1.1.2.4 HTTPResponse.py:NONE HTTPServer2.py:NONE

Shane Hathaway shane@digicool.com
Tue, 27 Nov 2001 12:01:21 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	HTTPServer.py PublisherServers.py 
Removed Files:
      Tag: Zope-3x-branch
	HTTPResponse.py HTTPServer2.py 
Log Message:
Removed old HTTPServer and HTTPResponse subclass and renamed HTTPServer2
to HTTPServer.


=== Zope3/lib/python/Zope/Server/HTTPServer.py 1.1.2.8 => 1.1.2.9 === (901/1001 lines abridged)
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 
 # FOR A PARTICULAR PURPOSE.
 
 """
-Medusa HTTP server for Zope
+This server uses asyncore to accept connections and do initial
+processing but threads to do work.
+"""
 
-changes from Medusa's http_server
+SIMULT_MODE = 0
 
-    Request Threads -- Requests are processed by threads from a thread
-    pool.
-    
-    Output Handling -- Output is pushed directly into the producer
-    fifo by the request-handling thread. The HTTP server does not do
-    any post-processing such as chunking.
-
-    Pipelineable -- This is needed for protocols such as HTTP/1.1 in
-    which mutiple requests come in on the same channel, before
-    responses are sent back. When requests are pipelined, the client
-    doesn't wait for the response before sending another request. The
-    server must ensure that responses are sent back in the same order
-    as requests are received.
-    
-""" 
-import sys
+import asyncore
 import re
-import os
-import types
-import thread
-import time
 import socket
+import sys
+import time
+from urllib import unquote
+
+from medusa.http_date import build_http_date, monthname
+from medusa import logger
+
+if SIMULT_MODE:
+    from dual_mode_channel import simultaneous_mode_channel as channel_type
+else:
+    from dual_mode_channel import dual_mode_channel as channel_type
+

[-=- -=- -=- 901 lines omitted -=- -=- -=-]

+    def readable (self):
+        return self.accepting
+        
+    def handle_connect (self):
+        pass
+
+    def handle_accept (self):
+        try:
+            v = self.accept()
+            if v is None:
+                return
+            conn, addr = v
+        except socket.error:
+                # linux: on rare occasions we get a bogus socket back from
+                # accept.  socketmodule.c:makesockaddr complains that the
+                # address family is unknown.  We don't want the whole server
+                # to shut down because of this.
+            self.log_info ('warning: server accept() threw an exception',
+                           'warning')
+            return
+        self.channel_class(self, conn, addr, self.adj)
+
+    def addTask(self, task):
+        tasks = self.tasks
+        if tasks is not None:
+            self.tasks.addTask(task)
+        else:
+            task.service()
+
+
+
+
 
-    def listen(self, num):
-        # override asyncore limits for nt's listen queue size
-        self.accepting = 1
-        return self.socket.listen (num)
 
+if __name__ == '__main__':
+    from TaskThreads import ThreadedTaskDispatcher
+    tasks = ThreadedTaskDispatcher()
+    tasks.setThreadCount(4)
+    http_server('', 8080, tasks=tasks)
+    try:
+        while 1:
+            asyncore.poll(5)
+            #print http_channel.active_channels
+    except KeyboardInterrupt:
+        print 'shutting down...'
+        tasks.shutdown()


=== Zope3/lib/python/Zope/Server/PublisherServers.py 1.1.2.3 => 1.1.2.4 ===
 from os import path as ospath
 
-from HTTPServer2 import http_task, http_channel, http_server
+from HTTPServer import http_task, http_channel, http_server
 
 from Zope.Publisher.Publish import publish
 from Zope.Publisher.HTTP.HTTPRequest import HTTPRequest

=== Removed File Zope3/lib/python/Zope/Server/HTTPResponse.py ===

=== Removed File Zope3/lib/python/Zope/Server/HTTPServer2.py ===