[Zope3-checkins] SVN: Zope3/branches/jinty-zodbless/src/zope/app/twisted/ Correct documentation and make the arguments of many functions reflect that they are being passed a resource factory rather than a ZODB database.

Brian Sutherland jinty at web.de
Mon Apr 9 11:34:18 EDT 2007


Log message for revision 74049:
  Correct documentation and make the arguments of many functions reflect that they are being passed a resource factory rather than a ZODB database.

Changed:
  U   Zope3/branches/jinty-zodbless/src/zope/app/twisted/README.txt
  U   Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/__init__.py
  U   Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py
  U   Zope3/branches/jinty-zodbless/src/zope/app/twisted/http.py
  U   Zope3/branches/jinty-zodbless/src/zope/app/twisted/interfaces.py
  U   Zope3/branches/jinty-zodbless/src/zope/app/twisted/server.py

-=-
Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/README.txt
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/README.txt	2007-04-09 14:51:29 UTC (rev 74048)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/README.txt	2007-04-09 15:34:17 UTC (rev 74049)
@@ -21,15 +21,15 @@
 arguments: the factory that will create a Twisted ``IServerFactory`` object
 and the default port and IP to which to bind the server.
 
-The ``factory`` argument should be a callable expecting one argument, the ZODB
-instance. It is up to the factory, to implement the necessary glue between the
-server and the application:
+The ``factory`` argument should be a callable expecting one argument, an object
+providing IResourceFactory. It is up to the factory, to implement the necessary
+glue between the server and the application:
 
   >>> class TwistedServerFactoryStub(object):
   ...     def doStart(self): pass
 
-  >>> def factory(db):
-  ...     print 'ZODB: %s' %db
+  >>> def factory(resource_factory):
+  ...     print 'Resource Factory: %s' % resource_factory
   ...     return TwistedServerFactoryStub()
 
 For the other two constructor arguments of ``ServerType``, the ``defaultPort``
@@ -55,13 +55,13 @@
 servers listening on a specific port.
 
 When you create an instance of a server using the ``create()`` method of the
-server type, you need to tell it an identifying name and a the ZODB database
+server type, you need to tell it an identifying name and a resource factory
 object. The IP address, port and backlog count can be optionally passed to the
 method.
 
-  >>> db = 'my database'
-  >>> server = st.create('Example-HTTP', db, port=0)
-  ZODB: my database
+  >>> resource_factory = 'my resource factory'
+  >>> server = st.create('Example-HTTP', resource_factory, port=0)
+  Resource Factory: my resource factory
   >>> server #doctest:+ELLIPSIS
   <zope.app.twisted.server.ZopeTCPServer instance at ...>
 
@@ -78,8 +78,8 @@
 You can, of course, create multiple instances of the same server type, and
 bind them to different ports.
 
-  >>> server2 = st.create('Example-HTTP-2', db, port=0)
-  ZODB: my database
+  >>> server2 = st.create('Example-HTTP-2', resource_factory, port=0)
+  Resource Factory: my resource factory
 
   >>> server2.startService()
   >>> print log.getvalue()
@@ -118,12 +118,12 @@
   >>> from zope.app.twisted.interfaces import IServerType
   >>> class MyServerType:
   ...     implements(IServerType)
-  ...     def create(self, name, db,
+  ...     def create(self, name, resource_factory,
   ...                port='unknown', ip='', backlog=50):
   ...         if not ip:
   ...             ip = '*' # listen on all interfaces
   ...         return ('%s server on %s:%d, registered with %s, backlog %d'
-  ...                 % (name, ip, port, db, backlog))
+  ...                 % (name, ip, port, resource_factory, backlog))
 
   >>> from zope.app.testing import ztapi
   >>> ztapi.provideUtility(IServerType, MyServerType(), name='HTTP')
@@ -142,26 +142,26 @@
     >>> from zope.app.twisted.server import ServerFactory
     >>> sf = ServerFactory(my_section)
 
-The server factory object knows how to create a server, given a ZODB database
-object.  The name is a combination of type, ip, and port, so that the Twisted
-code can distinguish between the different HTTP servers.
+The server factory object knows how to create a server, given a resource
+factory object.  The name is a combination of type, ip, and port, so that the
+Twisted code can distinguish between the different HTTP servers.
 
-    >>> db = 'my db'
-    >>> print sf.create(db)
-    HTTP:localhost:8080 server on *:8080, registered with my db, backlog 30
+    >>> resource_factory = 'my rf'
+    >>> print sf.create(resource_factory)
+    HTTP:localhost:8080 server on *:8080, registered with my rf, backlog 30
 
 It can create more than one, using different ports.
 
     >>> my_section.address = ('', 8081)
     >>> sf = ServerFactory(my_section)
-    >>> print sf.create(db)
-    HTTP:localhost:8081 server on *:8081, registered with my db, backlog 30
+    >>> print sf.create(resource_factory)
+    HTTP:localhost:8081 server on *:8081, registered with my rf, backlog 30
 
 The settings should actually work with FTP as well.
 
     >>> my_section.type = 'FTP'
     >>> my_section.address = ('127.0.0.1', 8021)
     >>> sf = ServerFactory(my_section)
-    >>> print sf.create(db)
-    FTP:127.0.0.1:8021 server on 127.0.0.1:8021, registered with my db, backlog 30
+    >>> print sf.create(resource_factory)
+    FTP:127.0.0.1:8021 server on 127.0.0.1:8021, registered with my rf, backlog 30
 

Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/__init__.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/__init__.py	2007-04-09 14:51:29 UTC (rev 74048)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/__init__.py	2007-04-09 15:34:17 UTC (rev 74049)
@@ -20,8 +20,8 @@
 
 from utils import FTPRequestFactory
 
-def createFTPFactory(db):
-    request_factory = FTPRequestFactory(db)
+def createFTPFactory(resource_factory):
+    request_factory = FTPRequestFactory(resource_factory)
 
     factory = FTPFactory(request_factory)
 

Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py	2007-04-09 14:51:29 UTC (rev 74048)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/ftp/utils.py	2007-04-09 15:34:17 UTC (rev 74049)
@@ -53,8 +53,8 @@
 class FTPRequestFactory(object):
     """FTP Request factory
 
-    FTP request factories for a given database create FTP requets with
-    publications on the given database:
+    FTP request factories for a given request factory create FTP requests with
+    publications on the given request factory:
 
       >>> from zope.app.publication.interfaces import IResourceFactory
       >>> class Stub:
@@ -69,8 +69,8 @@
     """
     implements(IPublicationRequestFactory)
 
-    def __init__(self, db):
-        self.publication = FTPPublication(db)
+    def __init__(self, resource_factory):
+        self.publication = FTPPublication(resource_factory)
 
     def __call__(self, input_stream, env):
         request = FTPRequest(input_stream, env)

Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/http.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/http.py	2007-04-09 14:51:29 UTC (rev 74048)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/http.py	2007-04-09 15:34:17 UTC (rev 74049)
@@ -52,8 +52,8 @@
         return stream.readStream(req.stream, temp.write).addCallback(done)
 
 
-def createHTTPFactory(db):
-    resource = wsgi.WSGIResource(WSGIPublisherApplication(db))
+def createHTTPFactory(resource_factory):
+    resource = wsgi.WSGIResource(WSGIPublisherApplication(resource_factory))
     resource = log.LogWrapperResource(resource)
     resource = Prebuffer(resource)
 
@@ -63,8 +63,8 @@
 https = SSLServerType(createHTTPFactory, 8443)
 
 
-def createPMHTTPFactory(db):
-    resource = wsgi.WSGIResource(PMDBWSGIPublisherApplication(db))
+def createPMHTTPFactory(resource_factory):
+    resource = wsgi.WSGIResource(PMDBWSGIPublisherApplication(resource_factory))
     resource = log.LogWrapperResource(resource)
     resource = Prebuffer(resource)
 

Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/interfaces.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/interfaces.py	2007-04-09 14:51:29 UTC (rev 74048)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/interfaces.py	2007-04-09 15:34:17 UTC (rev 74049)
@@ -27,7 +27,7 @@
     a ZCML directive and we shouldn't be able to change them.
     """
 
-    def create(name, db, ip=None, port=None, backlog=50):
+    def create(name, resource_factory, ip=None, port=None, backlog=50):
         """Create the server knowing the port, IP address and the ZODB.
 
         Returns the new server.
@@ -36,8 +36,8 @@
 class ISSLServerType(IServerType):
     """SSL Server Type utility"""
 
-    def create(name, db, privateKeyPath, certificatePath, tls=False,
-               ip=None, port=None, backlog=50):
+    def create(name, resource_factory, privateKeyPath, certificatePath,
+               tls=False, ip=None, port=None, backlog=50):
         """Create an SSL server instance.
 
         This differs only in respect to that it needs the private key path,
@@ -47,7 +47,8 @@
 class ISSHServerType(IServerType):
     """SSH Server Type utility"""
 
-    def create(name, db, hostkey, ip = None, port = None, backlog = 50):
+    def create(name, resource_factory, hostkey, ip = None, port = None,
+               backlog = 50):
         """Create a SSH server instance.
 
         This differs only in respect to that it needs the host key path.

Modified: Zope3/branches/jinty-zodbless/src/zope/app/twisted/server.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/twisted/server.py	2007-04-09 14:51:29 UTC (rev 74048)
+++ Zope3/branches/jinty-zodbless/src/zope/app/twisted/server.py	2007-04-09 15:34:17 UTC (rev 74049)
@@ -69,7 +69,7 @@
         self._defaultPort = defaultPort
         self._defaultIP = defaultIP
 
-    def create(self, name, db, ip=None, port=None, backlog=50):
+    def create(self, name, resource_factory, ip=None, port=None, backlog=50):
         'See IServerType'
         if port is None:
             port = self._defaultPort
@@ -77,8 +77,8 @@
         if ip is None:
             ip = self._defaultIP
 
-        # Given a database, create a twisted.internet.interfaces.IServerFactory
-        factory = self._factory(db)
+        # Given a resource_factory, create a twisted.internet.interfaces.IServerFactory
+        factory = self._factory(resource_factory)
         return ZopeTCPServer(name, port, factory, interface=ip, backlog=backlog)
 
 
@@ -86,7 +86,7 @@
 
     implements(IServerType)
 
-    def create(self, name, db, privateKeyPath, certificatePath, tls=False,
+    def create(self, name, resource_factory, privateKeyPath, certificatePath, tls=False,
                ip=None, port=None, backlog=50):
         'See IServerType'
         if port is None:
@@ -108,8 +108,8 @@
         contextFactory = ssl.DefaultOpenSSLContextFactory(
             privateKeyPath, certificatePath, method)
 
-        # Given a database, create a twisted.internet.interfaces.IServerFactory
-        factory = self._factory(db)
+        # Given a resource_factory, create a twisted.internet.interfaces.IServerFactory
+        factory = self._factory(resource_factory)
         return ZopeSSLServer(name, port, factory, contextFactory,
                              interface=ip, backlog=backlog)
 
@@ -118,7 +118,7 @@
 
     implements(ISSHServerType)
 
-    def create(self, name, db, hostkey, ip = None, port = None, backlog = 50):
+    def create(self, name, resource_factory, hostkey, ip = None, port = None, backlog = 50):
         """ """
         if port is None:
             port = self._defaultPort
@@ -126,8 +126,8 @@
         if ip is None:
             ip = self._defaultIP
 
-        # Given a database, create a twisted.internet.interfaces.IServerFactory
-        factory = self._factory(db, hostkey)
+        # Given a resource_factory, create a twisted.internet.interfaces.IServerFactory
+        factory = self._factory(resource_factory, hostkey)
         return ZopeTCPServer(name, port, factory, interface = ip,
                              backlog = backlog)
 
@@ -146,14 +146,14 @@
         self.address = section.address
         self.backlog = section.backlog
 
-    def create(self, database):
+    def create(self, resource_factory):
         """Return a server based on the server types defined via ZCML."""
 
         servertype = zapi.getUtility(IServerType, self.type)
         ip, port = self.address
         return servertype.create(
             '%s:%s:%d' % (self.type, ip or 'localhost', port),
-            database,
+            resource_factory,
             ip=ip,
             port=port,
             backlog=self.backlog)
@@ -171,14 +171,14 @@
         self.certificatePath = section.certificatepath
         self.tls = section.tls
 
-    def create(self, database):
+    def create(self, resource_factory):
         """Return a server based on the server types defined via ZCML."""
 
         servertype = zapi.getUtility(IServerType, self.type)
 
         return servertype.create(
             self.type,
-            database,
+            resource_factory,
             privateKeyPath = self.privateKeyPath,
             certificatePath = self.certificatePath,
             tls = self.tls,
@@ -198,14 +198,14 @@
         self.backlog = section.backlog
         self.hostkey = section.hostkey
 
-    def create(self, database):
+    def create(self, resource_factory):
         """Return a server based on the server types defined via ZCML."""
 
         servertype = zapi.getUtility(IServerType, self.type)
 
         return servertype.create(
             self.type,
-            database,
+            resource_factory,
             hostkey = self.hostkey,
             ip=self.address[0],
             port=self.address[1],



More information about the Zope3-Checkins mailing list