[Zope3-checkins] CVS: Zope3/src/zope/server - __init__.py:1.4 serverbase.py:1.4 serverchannelbase.py:1.4 taskthreads.py:1.5

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Feb 16 16:35:16 EST 2004


Update of /cvs-repository/Zope3/src/zope/server
In directory cvs.zope.org:/tmp/cvs-serv5858/src/zope/server

Modified Files:
	__init__.py serverbase.py serverchannelbase.py taskthreads.py 
Log Message:
Updated doc strings. Added documentation where necessary.


=== Zope3/src/zope/server/__init__.py 1.3 => 1.4 ===
--- Zope3/src/zope/server/__init__.py:1.3	Sat Jun  7 02:54:25 2003
+++ Zope3/src/zope/server/__init__.py	Mon Feb 16 16:34:37 2004
@@ -11,14 +11,17 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Zope 3's Servers
+
+This package contains generic base classes for channel-based servers, the
+servers themselves and helper objects, such as tasks and requests.
 
 $Id$
 """
-
 import asyncore
 
 from zope.server.interfaces import IDispatcher
 from zope.interface import classImplements
 
+# Tell the the async.dispatcher that it implements IDispatcher.
 classImplements(asyncore.dispatcher, IDispatcher)


=== Zope3/src/zope/server/serverbase.py 1.3 => 1.4 ===
--- Zope3/src/zope/server/serverbase.py:1.3	Wed Jun  4 04:40:32 2003
+++ Zope3/src/zope/server/serverbase.py	Mon Feb 16 16:34:37 2004
@@ -11,11 +11,13 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Server Base Class
+
+This module provides a base implementation for a channel-based server. It can
+only be used as a mix-in to actual server implementations.
 
 $Id$
 """
-
 import asyncore
 import logging
 import socket
@@ -26,11 +28,11 @@
 
 
 class ServerBase(asyncore.dispatcher, object):
-    """Async. server base for launching derivatives of ServerChannelBase.
-    """
+    """Async. server base for launching derivatives of ServerChannelBase."""
 
     implements(IServer)
 
+    # See zope.server.interfaces.IServer
     channel_class = None    # Override with a channel class.
     SERVER_IDENT = 'zope.server.serverbase'  # Override.
 
@@ -54,6 +56,7 @@
             self.accept_connections()
 
     def log(self, message):
+        """See zope.server.interfaces.IDispatcherLogging"""
         # Override asyncore's default log()
         self.logger.info(message)
 
@@ -64,9 +67,11 @@
         }
 
     def log_info(self, message, type='info'):
+        """See zope.server.interfaces.IDispatcherLogging"""
         self.logger.log(self.level_mapping.get(type, logging.INFO), message)
 
     def computeServerName(self, ip=''):
+        """Given an IP, try to determine the server name."""
         if ip:
             server_name = str(ip)
         else:
@@ -100,6 +105,7 @@
 
 
     def addTask(self, task):
+        """See zope.server.interfaces.ITaskDispatcher"""
         td = self.task_dispatcher
         if td is not None:
             td.addTask(task)
@@ -107,24 +113,24 @@
             task.service()
 
     def readable(self):
-        'See IDispatcher'
+        """See zope.server.interfaces.IDispatcher"""
         return (self.accepting and
                 len(asyncore.socket_map) < self.adj.connection_limit)
 
     def writable(self):
-        'See IDispatcher'
+        """See zope.server.interfaces.IDispatcher"""
         return 0
 
     def handle_read(self):
-        'See IDispatcherEventHandler'
+        """See zope.server.interfaces.IDispatcherEventHandler"""
         pass
 
     def handle_connect(self):
-        'See IDispatcherEventHandler'
+        """See zope.server.interfaces.IDispatcherEventHandler"""
         pass
 
     def handle_accept(self):
-        'See IDispatcherEventHandler'
+        """See zope.server.interfaces.IDispatcherEventHandler"""
         try:
             v = self.accept()
             if v is None:


=== Zope3/src/zope/server/serverchannelbase.py 1.3 => 1.4 ===
--- Zope3/src/zope/server/serverchannelbase.py:1.3	Wed Jun  4 04:40:32 2003
+++ Zope3/src/zope/server/serverchannelbase.py	Mon Feb 16 16:34:37 2004
@@ -11,11 +11,13 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Server-Channel Base Class
+
+This module provides a base implementation for the server channel. It can only
+be used as a mix-in to actual server channel implementations.
 
 $Id$
 """
-
 import os
 import time
 import sys
@@ -39,11 +41,11 @@
 
 
 class ServerChannelBase(ChannelBaseClass, object):
-    """Base class for a high-performance, mixed-mode server-side channel.
-    """
+    """Base class for a high-performance, mixed-mode server-side channel."""
 
     implements(IServerChannel)
 
+    # See zope.server.interfaces.IServerChannel
     parser_class = None       # Subclasses must provide a parser class
     task_class = None         # ... and a task class.
 
@@ -61,19 +63,24 @@
     #
 
     def __init__(self, server, conn, addr, adj=None):
+        """See async.dispatcher"""
         ChannelBaseClass.__init__(self, conn, addr, adj)
         self.server = server
         self.last_activity = t = self.creation_time
         self.check_maintenance(t)
 
     def add_channel(self, map=None):
-        """This hook keeps track of opened HTTP channels.
+        """See async.dispatcher
+
+        This hook keeps track of opened HTTP channels.
         """
         ChannelBaseClass.add_channel(self, map)
         self.__class__.active_channels[self._fileno] = self
 
     def del_channel(self, map=None):
-        """This hook keeps track of closed HTTP channels.
+        """See async.dispatcher
+
+        This hook keeps track of closed HTTP channels.
         """
         ChannelBaseClass.del_channel(self, map)
         ac = self.__class__.active_channels
@@ -82,7 +89,9 @@
             del ac[fd]
 
     def check_maintenance(self, now):
-        """Performs maintenance if necessary.
+        """See async.dispatcher
+
+        Performs maintenance if necessary.
         """
         ncc = self.__class__.next_channel_cleanup
         if now < ncc[0]:
@@ -91,12 +100,16 @@
         self.maintenance()
 
     def maintenance(self):
-        """Kills off dead connections.
+        """See async.dispatcher
+
+        Kills off dead connections.
         """
         self.kill_zombies()
 
     def kill_zombies(self):
-        """Closes connections that have not had any activity in a while.
+        """See async.dispatcher
+
+        Closes connections that have not had any activity in a while.
 
         The timeout is configured through adj.channel_timeout (seconds).
         """
@@ -108,7 +121,9 @@
                 channel.close()
 
     def received(self, data):
-        """Receive input asynchronously and send requests to
+        """See async.dispatcher
+
+        Receive input asynchronously and send requests to
         receivedCompleteRequest().
         """
         preq = self.proto_request
@@ -129,7 +144,9 @@
             data = data[n:]
 
     def receivedCompleteRequest(self, req):
-        """If there are tasks running or requests on hold, queue
+        """See async.dispatcher
+
+        If there are tasks running or requests on hold, queue
         the request, otherwise execute it.
         """
         do_now = 0
@@ -154,7 +171,9 @@
                 self.start_task(task)
 
     def start_task(self, task):
-        """Starts the given task.
+        """See async.dispatcher
+
+        Starts the given task.
 
         *** For thread safety, this should only be called from the main
         (async) thread. ***"""
@@ -167,7 +186,9 @@
         self.server.addTask(task)
 
     def handle_error(self):
-        """Handles program errors (not communication errors)
+        """See async.dispatcher
+
+        Handles program errors (not communication errors)
         """
         t, v = sys.exc_info()[:2]
         if t is SystemExit or t is KeyboardInterrupt:
@@ -175,7 +196,9 @@
         asyncore.dispatcher.handle_error(self)
 
     def handle_comm_error(self):
-        """Handles communication errors (not program errors)
+        """See async.dispatcher
+
+        Handles communication errors (not program errors)
         """
         if self.adj.log_socket_errors:
             self.handle_error()


=== Zope3/src/zope/server/taskthreads.py 1.4 => 1.5 ===
--- Zope3/src/zope/server/taskthreads.py:1.4	Wed Jun  4 04:40:32 2003
+++ Zope3/src/zope/server/taskthreads.py	Mon Feb 16 16:34:37 2004
@@ -1,4 +1,7 @@
-# Copyright 2001-2002 Zope Corporation and Contributors.  All Rights Reserved.
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
@@ -6,8 +9,12 @@
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Threaded Task Dispatcher
 
-
+$Id$
+"""
 from Queue import Queue, Empty
 from thread import allocate_lock, start_new_thread
 from time import time, sleep
@@ -18,6 +25,7 @@
 
 
 class ThreadedTaskDispatcher:
+    """A Task Dispatcher that creates a thread for each task."""
 
     implements(ITaskDispatcher)
 
@@ -51,6 +59,7 @@
                 mlock.release()
 
     def setThreadCount(self, count):
+        """See zope.server.interfaces.ITaskDispatcher"""
         mlock = self.thread_mgmt_lock
         mlock.acquire()
         try:
@@ -76,6 +85,7 @@
             mlock.release()
 
     def addTask(self, task):
+        """See zope.server.interfaces.ITaskDispatcher"""
         if task is None:
             raise ValueError, "No task passed to addTask()."
         # assert ITask.isImplementedBy(task)
@@ -86,7 +96,8 @@
             task.cancel()
             raise
 
-    def shutdown(self, cancel_pending=1, timeout=5):
+    def shutdown(self, cancel_pending=True, timeout=5):
+        """See zope.server.interfaces.ITaskDispatcher"""
         self.setThreadCount(0)
         # Ensure the threads shut down.
         threads = self.threads
@@ -107,4 +118,5 @@
                 pass
 
     def getPendingTasksEstimate(self):
+        """See zope.server.interfaces.ITaskDispatcher"""
         return self.queue.qsize()




More information about the Zope3-Checkins mailing list