[Zope-Checkins] SVN: Zope/trunk/ Removed experimental support for configuring the Twisted HTTP server.

Tres Seaver tseaver at palladion.com
Fri Sep 18 15:46:22 EDT 2009


Log message for revision 104359:
  Removed experimental support for configuring the Twisted HTTP server.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Lifetime/__init__.py
  U   Zope/trunk/src/Zope2/Startup/__init__.py
  U   Zope/trunk/src/Zope2/Startup/datatypes.py
  U   Zope/trunk/src/Zope2/Startup/handlers.py
  U   Zope/trunk/src/Zope2/Startup/zopeschema.xml
  U   Zope/trunk/src/Zope2/utilities/skel/etc/zope.conf.in

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2009-09-18 19:43:23 UTC (rev 104358)
+++ Zope/trunk/doc/CHANGES.rst	2009-09-18 19:46:22 UTC (rev 104359)
@@ -11,6 +11,9 @@
 Restructuring
 +++++++++++++
 
+- Removed experimental support for configuring the Twisted HTTP server
+  as an alternative to ``ZServer``.
+
 - Moved ``Products/Five/security.py`` into the AccessControl package.
 
 - Moved ``Products/Five/traversing.zcml`` directly into the configure.zcml.

Modified: Zope/trunk/src/Lifetime/__init__.py
===================================================================
--- Zope/trunk/src/Lifetime/__init__.py	2009-09-18 19:43:23 UTC (rev 104358)
+++ Zope/trunk/src/Lifetime/__init__.py	2009-09-18 19:46:22 UTC (rev 104359)
@@ -31,11 +31,6 @@
         import ZServer
         ZServer.exit_code = exit_code
         _shutdown_phase = 1
-        try:
-            from twisted.internet import reactor
-            reactor.callLater(0.1, reactor.stop)
-        except ImportError:
-            pass
     if fast:
         # Someone wants us to shutdown fast. This is hooked into SIGTERM - so
         # possibly the system is going down and we can expect a SIGKILL within

Modified: Zope/trunk/src/Zope2/Startup/__init__.py
===================================================================
--- Zope/trunk/src/Zope2/Startup/__init__.py	2009-09-18 19:43:23 UTC (rev 104358)
+++ Zope/trunk/src/Zope2/Startup/__init__.py	2009-09-18 19:46:22 UTC (rev 104359)
@@ -20,12 +20,6 @@
 import socket
 from re import compile
 from socket import gethostbyaddr
-try:
-    import twisted.internet.reactor
-    _use_twisted = True
-except ImportError:
-    _use_twisted = True
-    
 
 import ZConfig
 from ZConfig.components.logger import loghandler
@@ -94,8 +88,7 @@
         self.serverListen()
         from App.config import getConfiguration
         config = getConfiguration()
-        if not config.twisted_servers:
-            self.registerSignals()
+        self.registerSignals()
         # emit a "ready" message in order to prevent the kinds of emails
         # to the Zope maillist in which people claim that Zope has "frozen"
         # after it has emitted ZServer messages.
@@ -109,21 +102,9 @@
             from App.config import getConfiguration
             config = getConfiguration()
             import ZServer
-            if config.twisted_servers and config.servers:
-                raise ZConfig.ConfigurationError(
-                    "You can't run both ZServer servers and twisted servers.")
-            if config.twisted_servers:
-                if not _use_twisted:
-                    raise ZConfig.ConfigurationError(
-                        "You do not have twisted installed.")
-                twisted.internet.reactor.run()
-                # Storing the exit code in the ZServer even for twisted, 
-                # but hey, it works...
-                sys.exit(ZServer.exit_code)
-            else:
-                import Lifetime
-                Lifetime.loop()
-                sys.exit(ZServer.exit_code)
+            import Lifetime
+            Lifetime.loop()
+            sys.exit(ZServer.exit_code)
         finally:
             self.shutdown()
 

Modified: Zope/trunk/src/Zope2/Startup/datatypes.py
===================================================================
--- Zope/trunk/src/Zope2/Startup/datatypes.py	2009-09-18 19:43:23 UTC (rev 104358)
+++ Zope/trunk/src/Zope2/Startup/datatypes.py	2009-09-18 19:46:22 UTC (rev 104359)
@@ -325,12 +325,3 @@
         return getattr(m, name)
     except:
         return OFS.Uninstalled.Broken(jar, None, (module, name))
-
-try:
-    from zope.app.twisted.server import ServerFactory
-    class TwistedServerFactory(ServerFactory):
-        pass
-except ImportError:
-    class TwistedServerFactory:
-        def __init__(self, section):
-            raise ImportError("You do not have twisted installed.")

Modified: Zope/trunk/src/Zope2/Startup/handlers.py
===================================================================
--- Zope/trunk/src/Zope2/Startup/handlers.py	2009-09-18 19:43:23 UTC (rev 104358)
+++ Zope/trunk/src/Zope2/Startup/handlers.py	2009-09-18 19:46:22 UTC (rev 104359)
@@ -5,29 +5,6 @@
 from re import compile
 from socket import gethostbyaddr
 
-try:
-    import twisted.internet
-    from twisted.application.service import MultiService
-    import zope.app.twisted.main
-
-    import twisted.web2.wsgi
-    import twisted.web2.server
-    import twisted.web2.log
-    
-    try:
-        from twisted.web2.http import HTTPFactory
-    except ImportError:
-        from twisted.web2.channel.http import HTTPFactory
-    
-    from zope.component import provideUtility
-    from zope.app.twisted.server import ServerType, SSLServerType
-    from zope.app.twisted.interfaces import IServerType
-    from ZPublisher.WSGIPublisher import publish_module
-    
-    _use_twisted = True
-except ImportError:
-    _use_twisted = False
-
 # top-level key handlers
 
 
@@ -228,23 +205,6 @@
                         config.cgi_environment,
                         config.port_base)
 
-    if not config.twisted_servers:
-        config.twisted_servers = []
-    else:
-        # Set number of threads (reuse zserver_threads variable)
-        twisted.internet.reactor.suggestThreadPoolSize(config.zserver_threads)
-
-        # Create a root service
-        rootService = MultiService()
-
-        for server in config.twisted_servers:
-            service = server.create(None)
-            service.setServiceParent(rootService)
-
-        rootService.startService()
-        twisted.internet.reactor.addSystemEventTrigger(
-            'before', 'shutdown', rootService.stopService)
-
     # set up trusted proxies
     if config.trusted_proxies:
         import ZPublisher.HTTPRequest
@@ -264,23 +224,12 @@
 
 # DM 2004-11-24: added
 def _name2Ips(host, isIp_=compile(r'(\d+\.){3}').match):
-    '''map a name *host* to the sequence of its ip addresses;
+    """Map a name *host* to the sequence of its ip addresses.
+
     use *host* itself (as sequence) if it already is an ip address.
     Thus, if only a specific interface on a host is trusted,
     identify it by its ip (and not the host name).
-    '''
-    if isIp_(host): return [host]
+    """
+    if isIp_(host):
+        return [host]
     return gethostbyaddr(host)[2]
-
-
-# Twisted support:
-
-def createHTTPFactory(ignored):
-    resource = twisted.web2.wsgi.WSGIResource(publish_module)
-    resource = twisted.web2.log.LogWrapperResource(resource)
-
-    return HTTPFactory(twisted.web2.server.Site(resource))
-
-if _use_twisted:
-    http = ServerType(createHTTPFactory, 8080)
-    provideUtility(http, IServerType, 'Zope2-HTTP')

Modified: Zope/trunk/src/Zope2/Startup/zopeschema.xml
===================================================================
--- Zope/trunk/src/Zope2/Startup/zopeschema.xml	2009-09-18 19:43:23 UTC (rev 104358)
+++ Zope/trunk/src/Zope2/Startup/zopeschema.xml	2009-09-18 19:46:22 UTC (rev 104359)
@@ -11,12 +11,6 @@
   <import package="tempstorage"/>
   <import package="Zope2.Startup" file="warnfilter.xml"/>
 
-  <sectiontype name="server" datatype="Zope2.Startup.datatypes.TwistedServerFactory">
-    <key name="type" required="yes" />
-    <key name="address" datatype="inet-address" />
-    <key name="backlog" datatype="integer" default="50" />
-  </sectiontype>
-
   <sectiontype name="logger" datatype=".LoggerFactory">
     <description>
       This "logger" type only applies to access and request ("trace")
@@ -878,7 +872,6 @@
      <metadefault>on</metadefault>
   </key>
 
-  <multisection type="server" name="*" attribute="twisted_servers" />
   <multisection type="ZServer.server" name="*" attribute="servers"/>
 
   <key name="port-base" datatype="integer" default="0">

Modified: Zope/trunk/src/Zope2/utilities/skel/etc/zope.conf.in
===================================================================
--- Zope/trunk/src/Zope2/utilities/skel/etc/zope.conf.in	2009-09-18 19:43:23 UTC (rev 104358)
+++ Zope/trunk/src/Zope2/utilities/skel/etc/zope.conf.in	2009-09-18 19:46:22 UTC (rev 104359)
@@ -1005,15 +1005,7 @@
 #    user admin
 #    password 123
 #  </clock-server>
-#
-#  <server>
-#    # This uses Twisted as the web-server. You must install Twisted 
-#    # separately. You can't run Twisted and ZServer at same time.
-#    address 8080
-#    type Zope2-HTTP
-#  </server>
 
-
 # Database (zodb_db) section
 #
 # Description:



More information about the Zope-Checkins mailing list