[Zope3-checkins] SVN: Zope3/trunk/ Removed the machinery for configuring servers from ZCML.

Jim Fulton jim at zope.com
Wed Jun 2 15:30:13 EDT 2004


Log message for revision 25198:
Removed the machinery for configuring servers from ZCML.
This created a lot of unnecessary complexity.



-=-
Deleted: Zope3/trunk/package-includes/zope.app.server-meta.zcml
===================================================================
--- Zope3/trunk/package-includes/zope.app.server-meta.zcml	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/package-includes/zope.app.server-meta.zcml	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1 +0,0 @@
-<include package="zope.app.server" file="meta.zcml" />

Modified: Zope3/trunk/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/httpfactory.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/publication/httpfactory.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -15,20 +15,17 @@
 
 $Id$
 """
-from zope.interface import moduleProvides, implements
+from zope.interface import implements
 from zope.publisher.http import HTTPRequest
 from zope.publisher.browser import BrowserRequest
 from zope.publisher.xmlrpc import XMLRPCRequest
 
-from zope.app.publication.interfaces import IPublicationRequestFactoryFactory
 from zope.app.publication.interfaces import IPublicationRequestFactory
 
 from zope.app.publication.http import HTTPPublication
 from zope.app.publication.browser import BrowserPublication
 from zope.app.publication.xmlrpc import XMLRPCPublication
 
-moduleProvides(IPublicationRequestFactoryFactory)
-
 __metaclass__ = type
 
 _browser_methods = 'GET', 'POST', 'HEAD'
@@ -60,5 +57,3 @@
             request.setPublication(self._http)
 
         return request
-
-realize = HTTPPublicationRequestFactory

Modified: Zope3/trunk/src/zope/app/publication/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/interfaces.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/publication/interfaces.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -18,16 +18,6 @@
 
 from zope.interface import implements, Interface
 
-class IPublicationRequestFactoryFactory(Interface):
-    """Publication request factory factory"""
-
-    def realize(db):
-        """Create a publication and request factory for a given database
-
-        Return a IPublicationRequestFactory for the given database.
-        """
-
-
 class IPublicationRequestFactory(Interface):
     """Publication request factory"""
 
@@ -37,14 +27,6 @@
         A request is created and configured with a publication object.
         """
 
-
-class IRequestFactory(IPublicationRequestFactory,
-                      IPublicationRequestFactoryFactory):
-    """This is a pure read-only interface, since the values are set through
-       a ZCML directive and we shouldn't be able to change them.
-    """
-
-
 class IBeforeTraverseEvent(Interface):
     """An event which gets sent on publication traverse"""
 

Modified: Zope3/trunk/src/zope/app/server/PACKAGE.cfg
===================================================================
--- Zope3/trunk/src/zope/app/server/PACKAGE.cfg	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/PACKAGE.cfg	2004-06-02 19:30:12 UTC (rev 25198)
@@ -3,6 +3,5 @@
 <load>
 
 zope.app.server-configure.zcml svn://svn.zope.org/repos/main/Zope3/tags/*/package-includes/zope.app.server-configure.zcml
-zope.app.server-meta.zcml svn://svn.zope.org/repos/main/Zope3/tags/*/package-includes/zope.app.server-meta.zcml
 
 </load>

Modified: Zope3/trunk/src/zope/app/server/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/server/configure.zcml	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/configure.zcml	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,70 +1,25 @@
-<configure
-   xmlns="http://namespaces.zope.org/zope"
-   xmlns:startup="http://namespaces.zope.org/startup"
-   xmlns:event="http://namespaces.zope.org/event"
-   >
+<configure xmlns="http://namespaces.zope.org/zope">
 
   <utility 
       component=".servercontrol.serverControl"
       provides="zope.app.applicationcontrol.interfaces.IServerControl" />
 
-  <startup:registerRequestFactory 
-      name="HTTPRequestFactory"
-      factory="zope.app.publication.httpfactory"/>
-
-  <startup:registerRequestFactory 
-      name="BrowserRequestFactory"
-      publication="zope.app.publication.browser.BrowserPublication"
-      request="zope.publisher.browser.BrowserRequest" />
-
-  <startup:registerRequestFactory 
-      name="XMLRPCRequestFactory" 
-      publication="zope.app.publication.xmlrpc.XMLRPCPublication"
-      request="zope.publisher.xmlrpc.XMLRPCRequest"/>
-
-  <startup:registerRequestFactory 
-      name="FTPRequestFactory"
-      publication="zope.app.publication.ftp.FTPPublication"
-      request="zope.publisher.ftp.FTPRequest"/>
-
-  <startup:registerServerType 
+  <utility
       name="HTTP"
-      factory="zope.server.http.publisherhttpserver.PublisherHTTPServer"
-      requestFactory="HTTPRequestFactory"
-      logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
-      defaultPort="8080"
-      defaultVerbose="true" />
+      component=".http.http"
+      provides=".servertype.IServerType"
+      />
 
-  <startup:registerServerType 
+  <utility
       name="PostmortemDebuggingHTTP"
-      factory="zope.server.http.publisherhttpserver.PMDBHTTPServer"
-      requestFactory="HTTPRequestFactory"
-      logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
-      defaultPort="8013"
-      defaultVerbose="true" />
+      component=".http.pmhttp"
+      provides=".servertype.IServerType"
+      />
 
-  <startup:registerServerType 
-      name="Browser"
-      factory="zope.server.http.publisherhttpserver.PublisherHTTPServer"
-      requestFactory="BrowserRequestFactory"
-      logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
-      defaultPort="8080"
-      defaultVerbose="true" />
-
-  <startup:registerServerType 
-      name="XML-RPC"
-      factory="zope.server.http.publisherhttpserver.PublisherHTTPServer"
-      requestFactory="XMLRPCRequestFactory"
-      logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
-      defaultPort="8081"
-      defaultVerbose="true" />
-
-  <startup:registerServerType 
+  <utility
       name="FTP"
-      factory="zope.server.ftp.publisher.PublisherFTPServer"
-      requestFactory="FTPRequestFactory"
-      logFactory="zope.server.ftp.logger.CommonFTPActivityLogger"
-      defaultPort="8021"
-      defaultVerbose="true" />
+      component=".ftp.server"
+      provides=".servertype.IServerType"
+      />
 
 </configure>

Added: Zope3/trunk/src/zope/app/server/ftp.py
===================================================================
--- Zope3/trunk/src/zope/app/server/ftp.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/ftp.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""FTP server
+
+$Id$
+"""
+
+from zope.app.publication.ftp import FTPPublication
+from zope.app.publication.interfaces import IPublicationRequestFactory
+from zope.publisher.ftp import FTPRequest
+from zope.server.ftp.logger import CommonFTPActivityLogger
+from zope.server.ftp.publisher import PublisherFTPServer
+from zope.app.server.servertype import ServerType
+import zope.interface
+
+class FTPRequestFactory:
+    """FTP Request factory
+
+    FTP request factories for a given database create FTP requets with
+    publications on the given database:
+        
+      >>> from ZODB.tests.util import DB
+      >>> db = DB()
+      >>> factory = FTPRequestFactory(db)
+      >>> from cStringIO import StringIO
+      >>> request = factory(StringIO(''), StringIO(),
+      ...                   {'credentials': None, 'path': '/'})
+      >>> request.publication.db is db
+      True
+      >>> db.close()
+
+    """
+    zope.interface.implements(IPublicationRequestFactory)
+
+    def __init__(self, db):
+        self.publication = FTPPublication(db)
+
+    def __call__(self, input_stream, output_steam, env):
+        request = FTPRequest(input_stream, output_steam, env)
+        request.setPublication(self.publication)
+        return request
+
+server = ServerType(
+    PublisherFTPServer,
+    FTPRequestFactory,
+    CommonFTPActivityLogger,
+    8021, True)


Property changes on: Zope3/trunk/src/zope/app/server/ftp.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: Zope3/trunk/src/zope/app/server/http.py
===================================================================
--- Zope3/trunk/src/zope/app/server/http.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/http.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""HTTP server factories
+
+$Id$
+"""
+
+from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
+from zope.app.server.servertype import ServerType
+from zope.server.http.commonhitlogger import CommonHitLogger
+from zope.server.http.publisherhttpserver import PMDBHTTPServer
+from zope.server.http.publisherhttpserver import PublisherHTTPServer
+
+http = ServerType(PublisherHTTPServer,
+                  HTTPPublicationRequestFactory,
+                  CommonHitLogger,
+                  8080, True)
+
+pmhttp = ServerType(PMDBHTTPServer,
+                    HTTPPublicationRequestFactory,
+                    CommonHitLogger,
+                    8013, True)


Property changes on: Zope3/trunk/src/zope/app/server/http.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Deleted: Zope3/trunk/src/zope/app/server/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/server/interfaces.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/interfaces.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,44 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interfaces for the zope.app.server package.
-
-$Id$
-"""
-
-from zope.interface import Interface
-
-class ISimpleRegistry(Interface):
-    """
-    The Simple Registry is minimal collection of registered objects. This can
-    be useful, when it is expected that objects of a particular type are added
-    from many places in the system (through 3rd party products for example).
-
-    A good example for this are the Formulator fields. While the basic types
-    are defined inside the Formulator tree, other parties might add many
-    more later on in their products, so it is useful to provide a registry via
-    ZCML that allows to collect these items.
-
-    There is only one constraint on the objects. They all must implement a
-    particular interface specified during the initialization of the registry.
-
-    Note that it does not matter whether we have classes or instances as
-    objects. If the objects are instances, they must implement simply
-    IInstanceFactory.
-    """
-
-    def register(name, object):
-        """Registers the object under the id name."""
-
-    def getF(name):
-        """This returns the object with id name."""

Deleted: Zope3/trunk/src/zope/app/server/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/server/meta.zcml	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/meta.zcml	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,17 +0,0 @@
-<configure 
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta">
-
-  <meta:directive 
-      name="registerRequestFactory"
-      namespace="http://namespaces.zope.org/startup"
-      schema=".metadirectives.IRegisterRequestFactoryDirective"
-      handler=".metaconfigure.registerRequestFactory" />
-
-  <meta:directive 
-      name="registerServerType"
-      namespace="http://namespaces.zope.org/startup"
-      schema=".metadirectives.IRegisterServerTypeDirective"
-      handler=".metaconfigure.registerServerType"/>
-
-</configure>

Deleted: Zope3/trunk/src/zope/app/server/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/server/metaconfigure.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/metaconfigure.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""This module handles the 'startup' ZCML namespace directives.
-
-$Id$
-"""
-from zope.app.server import requestfactoryregistry
-from zope.app.server import servertyperegistry
-from zope.app.server.requestfactory import RequestFactory
-from zope.app.server.servertype import ServerType
-
-
-def registerRequestFactory(_context, name, request=None, publication=None,
-                           factory=None):
-
-    if factory:
-        if request or publication:
-            raise ValuesError(
-                """You cannot provide a request or publication (factory) if you
-                provide a (request) factory""")
-        request_factory = factory
-
-    else:
-        request_factory = RequestFactory(publication, request)
-
-    _context.action(
-            discriminator = name,
-            callable = requestfactoryregistry.registerRequestFactory,
-            args = (name, request_factory,) )
-
-
-def registerServerType(_context, name, factory, requestFactory, logFactory,
-                       defaultPort, defaultVerbose):
-
-    server_type = ServerType(name, factory, requestFactory, logFactory,
-                             defaultPort, defaultVerbose)
-
-    _context.action(
-            discriminator = name,
-            callable = servertyperegistry.registerServerType,
-            args = (name, server_type) )

Deleted: Zope3/trunk/src/zope/app/server/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/server/metadirectives.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/metadirectives.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,87 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Schemas for the 'startup' ZCML Namespace
-
-$Id$
-"""
-from zope.configuration.fields import GlobalObject, Bool
-from zope.interface import Interface
-from zope.schema import TextLine, BytesLine, Int
-
-
-class IBaseStartup(Interface):
-    """Interface that specified common attributes of the startup
-    directives."""
-    
-    publication = GlobalObject(
-        title=u"Publication",
-        description=u"Specifies the Publication component for which this " \
-                    u"request is used.",
-        required=False)
-
-    request = GlobalObject(
-        title=u"Request",
-        description=u"Request component that is being instantiated.",
-        required=False)
-
-
-class IRegisterRequestFactoryDirective(IBaseStartup):
-    """Register a particular request factory that can be used by a server."""
-    
-    name = TextLine(
-        title=u"Name",
-        description=u"Name of the request factory",
-        required=True)
-
-    factory = GlobalObject(
-        title=u"Factory",
-        description=u"If specified, this factory is used to create the" \
-                    u"request.",
-        required=False)
-
-
-class IRegisterServerTypeDirective(IBaseStartup):
-    """Register a server type."""
-
-    name = TextLine(
-        title=u"Name",
-        description=u"Name as which the server will be known.",
-        required=True)
-
-    factory = GlobalObject(
-        title=u"Factory",
-        description=u"This factory is used to create the server component.",
-        required=True)
-
-    requestFactory = BytesLine(
-        title=u"Request Factory",
-        description=u"This is the factory id that is used to create the" \
-                    u"request.",
-        required=True)
-
-    defaultPort = Int(
-        title=u"Default Port",
-        description=u"Start the server on this port, if no port is specified.",
-        required=True)
-
-    logFactory = GlobalObject(
-        title=u"Log Factory",
-        description=u"This factory is used to create the logging component.",
-        required=True)
-
-    defaultVerbose = Bool(
-        title=u"Default Verbose",
-        description=u"If not specifed, should the server start in verbose" \
-                    u"mode.",
-        required=True)

Deleted: Zope3/trunk/src/zope/app/server/refactor.txt
===================================================================
--- Zope3/trunk/src/zope/app/server/refactor.txt	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/refactor.txt	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,18 +0,0 @@
-The code here and in zope._app is more complicated than it needs to be.
-
-Here's what I want to do:
-
-- Move the definition of request and server factories to Python
-
-- Register the server factories (aka server types) as utilities.
-  
-
-These let us rip out most of the code here. :)
-
-Move the rest of the code here to zope.app.server.  The
-zope.app.server package is just tha zope.app. customization of
-zope.server.
-
-Rename zope._app to zope.app.debug. Move the config function from
-zope.app.debug into zope.app.setup.  Move the bootstrap code to
-zope.app.setup.

Deleted: Zope3/trunk/src/zope/app/server/requestfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/server/requestfactory.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/requestfactory.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,47 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Request Factory
-
-$Id$
-"""
-import copy
-from zope.app.publication.interfaces import IRequestFactory
-from zope.interface import implements
-
-class RequestFactory:
-    """This class will generically create RequestFactories. This way I do
-       not have to create a method for each Server Type there is.
-    """
-
-    implements(IRequestFactory)
-
-    def __init__(self, publication, request):
-        """Initialize Request Factory"""
-        self._pubFactory = publication
-        self._publication = None
-        self._request = request
-
-
-    def realize(self, db):
-        'See IRequestFactory'
-        realized = copy.copy(self)
-        realized._publication = realized._pubFactory(db)
-        return realized
-
-
-    def __call__(self, input_stream, output_steam, env):
-        'See IRequestFactory'
-        request = self._request(input_stream, output_steam, env)
-        request.setPublication(self._publication)
-        return request

Deleted: Zope3/trunk/src/zope/app/server/requestfactoryregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/server/requestfactoryregistry.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/requestfactoryregistry.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,48 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id$
-"""
-from zope.interface import implements
-from zope.app.server.interfaces import ISimpleRegistry
-from zope.app.publication.interfaces import IPublicationRequestFactoryFactory
-from zope.app.server.simpleregistry import SimpleRegistry
-
-
-class IRequestFactoryRegistry(ISimpleRegistry):
-    """
-    The RequestFactory Registry manages a list of all the fields
-    available in Zope. A registry is useful at this point, since
-    fields can be initialized and registered by many places.
-
-    Note that it does not matter whether we have classes or instances as
-    fields. If the fields are instances, they must implement
-    IInstanceFactory.
-    """
-
-
-class RequestFactoryRegistry(SimpleRegistry):
-    implements(IRequestFactoryRegistry)
-
-
-RequestFactoryRegistry = RequestFactoryRegistry(
-    IPublicationRequestFactoryFactory)
-
-registerRequestFactory = RequestFactoryRegistry.register
-getRequestFactory = RequestFactoryRegistry.get
-
-# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
-from zope.testing.cleanup import addCleanUp
-addCleanUp(RequestFactoryRegistry._clear)
-del addCleanUp

Modified: Zope3/trunk/src/zope/app/server/server.py
===================================================================
--- Zope3/trunk/src/zope/app/server/server.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/server.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -19,8 +19,9 @@
 $Id$
 """
 
-from zope.app.server.servertyperegistry import getServerType
 
+from zope.app import zapi
+from zope.app.server.servertype import IServerType
 
 class ServerFactory:
     """Factory for server objects.
@@ -37,8 +38,11 @@
 
     def create(self, task_dispatcher, database):
         """Return a server based on the server types defined via ZCML."""
-        servertype = getServerType(self.type)
+
+        servertype = zapi.getUtility(IServerType, self.type)
         # The server object self-registers with the asyncore mainloop.
-        servertype.create(task_dispatcher, database,
-                          self.address[1], # XXX maybe improve API
-                          self.verbose)
+        servertype.create(
+            self.type,
+            task_dispatcher, database,
+            self.address[1], # XXX maybe improve API
+            self.verbose)

Modified: Zope3/trunk/src/zope/app/server/servertype.py
===================================================================
--- Zope3/trunk/src/zope/app/server/servertype.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/servertype.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -15,7 +15,6 @@
 """
 
 from zope.interface import Interface, implements
-from zope.app.server.requestfactoryregistry import getRequestFactory
 
 
 class IServerType(Interface):
@@ -31,10 +30,8 @@
 
     implements(IServerType)
 
-    def __init__(self, name, factory, requestFactory, logFactory,
+    def __init__(self, factory, requestFactory, logFactory,
                  defaultPort, defaultVerbose):
-        """ """
-        self._name = name
         self._factory = factory
         self._requestFactory = requestFactory
         self._logFactory = logFactory
@@ -42,11 +39,10 @@
         self._defaultVerbose = defaultVerbose
 
 
-    def create(self, task_dispatcher, db, port=None, verbose=None):
+    def create(self, name, task_dispatcher, db, port=None, verbose=None):
         'See IServerType'
 
-        request_factory = getRequestFactory(self._requestFactory)
-        request_factory = request_factory.realize(db)
+        request_factory = self._requestFactory(db)
 
         if port is None:
             port = self._defaultPort
@@ -54,8 +50,8 @@
         if verbose is None:
             verbose = self._defaultVerbose
 
-        apply(self._factory,
-              (request_factory, self._name, '', port),
-              {'task_dispatcher': task_dispatcher,
-               'verbose': verbose,
-               'hit_log': self._logFactory()})
+        self._factory(request_factory, name, '', port,
+                      task_dispatcher=task_dispatcher,
+                      verbose=verbose,
+                      hit_log=self._logFactory(),
+                      )

Deleted: Zope3/trunk/src/zope/app/server/servertyperegistry.py
===================================================================
--- Zope3/trunk/src/zope/app/server/servertyperegistry.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/servertyperegistry.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,47 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id$
-"""
-from zope.app.server.interfaces import ISimpleRegistry
-from zope.app.server.servertype import IServerType
-from zope.app.server.simpleregistry import SimpleRegistry
-from zope.interface import implements
-
-
-class IServerTypeRegistry(ISimpleRegistry):
-    """
-    The ServerType Registry manages a list of all the fields
-    available in Zope. A registry is useful at this point, since
-    fields can be initialized and registered by many places.
-
-    Note that it does not matter whether we have classes or instances as
-    fields. If the fields are instances, they must implement
-    IInstanceFactory.
-    """
-
-
-class ServerTypeRegistry(SimpleRegistry):
-    """Registry for the various Server types"""
-    implements(IServerTypeRegistry)
-
-
-ServerTypeRegistry = ServerTypeRegistry(IServerType)
-registerServerType = ServerTypeRegistry.register
-getServerType = ServerTypeRegistry.get
-
-# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
-from zope.testing.cleanup import addCleanUp
-addCleanUp(ServerTypeRegistry._clear)
-del addCleanUp

Deleted: Zope3/trunk/src/zope/app/server/simpleregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/server/simpleregistry.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/simpleregistry.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,86 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id$
-"""
-from zope.app.server.interfaces import ISimpleRegistry
-from zope.interface import implements
-
-ListTypes = (tuple, list)
-
-
-class ZopeDuplicateRegistryEntryError(Exception):
-    """
-    This Error is raised when the user tries to add an object with
-    a name that already exists in the registry. Therefore,
-    overwriting is not allowed.
-    """
-
-    def __init__(self, name):
-        """Initializes Error"""
-        self.name = name
-
-    def __str__(self):
-        """Returns string representation of Error"""
-        return "The name '%s' is already defined in this registry." \
-               %self.name
-
-
-class ZopeIllegalInterfaceError(Exception):
-    """This Error is thrown, when the passed object does not implement
-    the specified interface."""
-
-    def __init__(self, name, interface):
-        """Initalize Error"""
-        self.name = name
-        self.interface = interface
-
-    def __str__(self):
-        """Returns string representation of Error"""
-        return ("The object with name " + self.name + " does not implement "
-                "the interface " + self.interface.getName() + ".")
-
-
-class SimpleRegistry:
-    """ """
-
-    implements(ISimpleRegistry)
-
-    def __init__(self, interface):
-        """Initialize registry"""
-        self.objects = {}
-        self.interface = interface
-
-    def _clear(self):
-        self.objects.clear()
-
-    def register(self, name, object):
-        '''See ISimpleRegistry'''
-
-        if name in self.objects.keys():
-            raise ZopeDuplicateRegistryEntryError(name)
-
-        if self.interface.providedBy(object):
-            self.objects[name] = object
-        else:
-            raise ZopeIllegalInterfaceError(name, self.interface)
-
-        return []
-
-    def get(self, name):
-        '''See ISimpleRegistry'''
-        if name in self.objects.keys():
-            return self.objects[name]
-        else:
-            return None

Deleted: Zope3/trunk/src/zope/app/server/tests/startup.zcml
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/startup.zcml	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/tests/startup.zcml	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,23 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
-           xmlns:startup="http://namespaces.zope.org/startup">
-
-  <include package="zope.app.server" file="meta.zcml"/>
-
-  <startup:registerServerType
-      name="Browser"
-      factory="zope.server.http.publisherhttpserver.PublisherHTTPServer"
-      requestFactory="BrowserRequestFactory"
-      logFactory="zope.server.http.commonhitlogger.CommonHitLogger"
-      defaultPort="8080"
-      defaultVerbose="true" />
-
-  <startup:registerRequestFactory
-      name="BrowserRequestFactory"
-      publication="zope.app.publication.browser.BrowserPublication"
-      request="zope.publisher.browser.BrowserRequest"/>
-
-  <startup:registerRequestFactory
-      name="BrowserRequestFactory2"
-      factory="zope.app.server.tests.test_directives.tf"/>
- 
-</configure>

Deleted: Zope3/trunk/src/zope/app/server/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_directives.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/tests/test_directives.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,71 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""startup ZCML namespace directive tests
-
-$Id$
-"""
-import unittest
-from zope.app.publication.interfaces import IPublicationRequestFactoryFactory
-from zope.app.server.requestfactoryregistry import getRequestFactory
-from zope.app.server.servertyperegistry import getServerType
-from zope.app.publication.browser import BrowserPublication
-from zope.configuration import xmlconfig
-from zope.interface import implements
-from zope.publisher.browser import BrowserRequest
-from zope.server.http.publisherhttpserver import PublisherHTTPServer
-from zope.server.http.commonhitlogger import CommonHitLogger
-from zope.testing.cleanup import CleanUp
-import zope.app.server.tests
-
-class TF:
-    "test request factory"
-    implements(IPublicationRequestFactoryFactory)
-
-tf = TF()
-
-
-class DirectivesTest(CleanUp, unittest.TestCase):
-
-    def setUp(self):
-        CleanUp.setUp(self)
-        self.context = xmlconfig.file("startup.zcml", zope.app.server.tests)
-
-    def test_registerServerType(self):
-        self.assertEqual(getServerType('Browser')._factory,
-                         PublisherHTTPServer)
-        self.assertEqual(getServerType('Browser')._logFactory, CommonHitLogger)
-        self.assertEqual(getServerType('Browser')._requestFactory,
-                         "BrowserRequestFactory")
-        self.assertEqual(getServerType('Browser')._defaultPort, 8080)
-        self.assertEqual(getServerType('Browser')._defaultVerbose, True)
-
-    def test_registerRequestFactory(self):
-        self.assertEqual(
-            getRequestFactory('BrowserRequestFactory')._pubFactory,
-            BrowserPublication)
-        self.assertEqual(
-            getRequestFactory('BrowserRequestFactory')._request,
-            BrowserRequest)
-
-    def test_registerRequestFactory_with_Factory(self):
-        self.assertEqual(getRequestFactory('BrowserRequestFactory2'), tf)
-
-
-def test_suite():
-    return unittest.TestSuite((
-        unittest.makeSuite(DirectivesTest),
-        ))
-
-if __name__ == '__main__':
-    unittest.main()

Deleted: Zope3/trunk/src/zope/app/server/tests/test_requestfactoryregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_requestfactoryregistry.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/tests/test_requestfactoryregistry.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,51 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-I do not think it is necessary to do the entire SimpleRegistry tests again.
-Instead we will test whether the module in itself works.
-
-$Id$
-"""
-
-import unittest
-from zope.app.server.requestfactoryregistry import \
-     registerRequestFactory, getRequestFactory
-from zope.app.publication.interfaces import IRequestFactory
-from zope.interface import implements
-
-
-class RequestFactory:
-    """RequestFactory Stub."""
-
-    implements(IRequestFactory)
-
-
-class Test(unittest.TestCase):
-
-
-    def testRegistry(self):
-
-        factory = RequestFactory()
-
-        registerRequestFactory('factory', factory)
-        self.assertEqual(getRequestFactory('factory'), factory)
-
-
-def test_suite():
-    loader = unittest.TestLoader()
-    return loader.loadTestsFromTestCase(Test)
-
-
-if __name__=='__main__':
-    unittest.TextTestRunner().run(test_suite())

Deleted: Zope3/trunk/src/zope/app/server/tests/test_servertyperegistry.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_servertyperegistry.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/tests/test_servertyperegistry.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,51 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-I do not think it is necessary to do the entire SimpleRegistry tests again.
-Instead we will test whether the module in itself works.
-
-$Id$
-"""
-
-import unittest
-from zope.app.server.servertyperegistry import \
-     registerServerType, getServerType
-from zope.app.server.servertype import IServerType
-from zope.interface import implements
-
-
-class ServerType:
-    """ServerType Stub."""
-
-    implements(IServerType)
-
-
-class Test(unittest.TestCase):
-
-
-    def testRegistry(self):
-
-        server = ServerType()
-
-        registerServerType('server', server)
-        self.assertEqual(getServerType('server'), server)
-
-
-def test_suite():
-    loader = unittest.TestLoader()
-    return loader.loadTestsFromTestCase(Test)
-
-
-if __name__=='__main__':
-    unittest.TextTestRunner().run(test_suite())

Deleted: Zope3/trunk/src/zope/app/server/tests/test_simpleregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_simpleregistry.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/app/server/tests/test_simpleregistry.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -1,99 +0,0 @@
-##############################################################################
-#
-# 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.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# 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
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-import unittest
-from zope.interface import Interface
-from zope.app.server.simpleregistry import SimpleRegistry, \
-     ZopeDuplicateRegistryEntryError, ZopeIllegalInterfaceError
-from zope.interface import implements
-
-
-class I1(Interface):
-    pass
-
-
-class I2(Interface):
-    pass
-
-
-class Object1:
-    implements(I1)
-
-
-class Object2:
-    implements(I2)
-
-
-class Test(unittest.TestCase):
-
-
-    def testRegister(self):
-
-        registry = SimpleRegistry(I1)
-        obj1 = Object1()
-
-        self.assertEqual(registry.objects, {})
-
-        registry.register('obj1', obj1)
-        self.assertEqual(registry.objects, {'obj1': obj1})
-
-        registry.register('obj2', obj1)
-        self.assertEqual(registry.objects, {'obj1': obj1, 'obj2': obj1})
-
-
-    def testIllegalInterfaceError(self):
-
-        registry = SimpleRegistry(I1)
-        obj2 = Object2()
-
-        self.failUnlessRaises(ZopeIllegalInterfaceError,
-                              registry.register, 'obj2', obj2)
-
-
-    def testDuplicateEntry(self):
-
-        registry = SimpleRegistry(I1)
-        obj1 = Object1()
-        registry.register('obj1', obj1)
-
-        self.failUnlessRaises(ZopeDuplicateRegistryEntryError,
-                              registry.register, 'obj1', obj1)
-
-
-    def testGet(self):
-
-        registry = SimpleRegistry(I1)
-        obj1 = Object1()
-        obj2 = Object1()
-        registry.objects = {'obj1': obj1, 'obj2': obj2}
-
-        self.assertEqual(registry.get('obj1'), obj1)
-        self.assertEqual(registry.get('obj2'), obj2)
-
-        # Requesting an object that does not exist
-        self.assertEqual(registry.get('obj3'), None)
-
-
-
-def test_suite():
-    loader = unittest.TestLoader()
-    return loader.loadTestsFromTestCase(Test)
-
-
-if __name__=='__main__':
-    unittest.TextTestRunner().run(test_suite())

Modified: Zope3/trunk/src/zope/server/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/server/interfaces/__init__.py	2004-06-02 19:27:47 UTC (rev 25197)
+++ Zope3/trunk/src/zope/server/interfaces/__init__.py	2004-06-02 19:30:12 UTC (rev 25198)
@@ -134,18 +134,6 @@
         a different thread.
         """
 
-
-class IRequestFactory:
-
-    def __call__(input_stream, output_steam, environment):
-        """Create a request object *with* a publication
-
-        Factories that support multiple request/response/publication
-        types may look at the environment (headers) or the stream to
-        determine which request/response/publication to create.
-        """
-
-
 class IHeaderOutput(Interface):
     """Interface for setting HTTP response headers.
 




More information about the Zope3-Checkins mailing list