[Zope-Checkins] SVN: Zope/branches/2.12/ Backport removal of experimental support for configuring the Twisted HTTP server as an alternative to ``ZServer``.

Tres Seaver tseaver at palladion.com
Tue Sep 22 15:06:35 EDT 2009


Log message for revision 104434:
  Backport removal of experimental support for configuring the Twisted HTTP server as an alternative to ``ZServer``.
  

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

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2009-09-22 18:59:58 UTC (rev 104433)
+++ Zope/branches/2.12/doc/CHANGES.rst	2009-09-22 19:06:30 UTC (rev 104434)
@@ -21,6 +21,9 @@
 Bugs Fixed
 ++++++++++
 
+- Backported removal of experimental support for configuring the Twisted HTTP
+  server as an alternative to ``ZServer``.
+
 - Backported fix for timezone issues in date index tests from trunk.
 
 - LP #414757 (backported from Zope trunk): don't emit a IEndRequestEvent when

Modified: Zope/branches/2.12/src/Lifetime/__init__.py
===================================================================
--- Zope/branches/2.12/src/Lifetime/__init__.py	2009-09-22 18:59:58 UTC (rev 104433)
+++ Zope/branches/2.12/src/Lifetime/__init__.py	2009-09-22 19:06:30 UTC (rev 104434)
@@ -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/branches/2.12/src/Zope2/Startup/__init__.py
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/__init__.py	2009-09-22 18:59:58 UTC (rev 104433)
+++ Zope/branches/2.12/src/Zope2/Startup/__init__.py	2009-09-22 19:06:30 UTC (rev 104434)
@@ -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/branches/2.12/src/Zope2/Startup/datatypes.py
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/datatypes.py	2009-09-22 18:59:58 UTC (rev 104433)
+++ Zope/branches/2.12/src/Zope2/Startup/datatypes.py	2009-09-22 19:06:30 UTC (rev 104434)
@@ -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/branches/2.12/src/Zope2/Startup/handlers.py
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/handlers.py	2009-09-22 18:59:58 UTC (rev 104433)
+++ Zope/branches/2.12/src/Zope2/Startup/handlers.py	2009-09-22 19:06:30 UTC (rev 104434)
@@ -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/branches/2.12/src/Zope2/Startup/zopeschema.xml
===================================================================
--- Zope/branches/2.12/src/Zope2/Startup/zopeschema.xml	2009-09-22 18:59:58 UTC (rev 104433)
+++ Zope/branches/2.12/src/Zope2/Startup/zopeschema.xml	2009-09-22 19:06:30 UTC (rev 104434)
@@ -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/branches/2.12/src/Zope2/utilities/skel/etc/zope.conf.in
===================================================================
--- Zope/branches/2.12/src/Zope2/utilities/skel/etc/zope.conf.in	2009-09-22 18:59:58 UTC (rev 104433)
+++ Zope/branches/2.12/src/Zope2/utilities/skel/etc/zope.conf.in	2009-09-22 19:06:30 UTC (rev 104434)
@@ -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