Commit 5f08da6e authored by Tres Seaver's avatar Tres Seaver

Removed experimental support for configuring the Twisted HTTP server.

parent 23ffd056
...@@ -11,6 +11,9 @@ Trunk (unreleased) ...@@ -11,6 +11,9 @@ Trunk (unreleased)
Restructuring 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/security.py`` into the AccessControl package.
- Moved ``Products/Five/traversing.zcml`` directly into the configure.zcml. - Moved ``Products/Five/traversing.zcml`` directly into the configure.zcml.
......
...@@ -31,11 +31,6 @@ def shutdown(exit_code,fast = 0): ...@@ -31,11 +31,6 @@ def shutdown(exit_code,fast = 0):
import ZServer import ZServer
ZServer.exit_code = exit_code ZServer.exit_code = exit_code
_shutdown_phase = 1 _shutdown_phase = 1
try:
from twisted.internet import reactor
reactor.callLater(0.1, reactor.stop)
except ImportError:
pass
if fast: if fast:
# Someone wants us to shutdown fast. This is hooked into SIGTERM - so # 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 # possibly the system is going down and we can expect a SIGKILL within
......
...@@ -20,12 +20,6 @@ import sys ...@@ -20,12 +20,6 @@ import sys
import socket import socket
from re import compile from re import compile
from socket import gethostbyaddr from socket import gethostbyaddr
try:
import twisted.internet.reactor
_use_twisted = True
except ImportError:
_use_twisted = True
import ZConfig import ZConfig
from ZConfig.components.logger import loghandler from ZConfig.components.logger import loghandler
...@@ -94,7 +88,6 @@ class ZopeStarter: ...@@ -94,7 +88,6 @@ class ZopeStarter:
self.serverListen() self.serverListen()
from App.config import getConfiguration from App.config import getConfiguration
config = getConfiguration() config = getConfiguration()
if not config.twisted_servers:
self.registerSignals() self.registerSignals()
# emit a "ready" message in order to prevent the kinds of emails # emit a "ready" message in order to prevent the kinds of emails
# to the Zope maillist in which people claim that Zope has "frozen" # to the Zope maillist in which people claim that Zope has "frozen"
...@@ -109,18 +102,6 @@ class ZopeStarter: ...@@ -109,18 +102,6 @@ class ZopeStarter:
from App.config import getConfiguration from App.config import getConfiguration
config = getConfiguration() config = getConfiguration()
import ZServer 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 import Lifetime
Lifetime.loop() Lifetime.loop()
sys.exit(ZServer.exit_code) sys.exit(ZServer.exit_code)
......
...@@ -325,12 +325,3 @@ def simpleClassFactory(jar, module, name, ...@@ -325,12 +325,3 @@ def simpleClassFactory(jar, module, name,
return getattr(m, name) return getattr(m, name)
except: except:
return OFS.Uninstalled.Broken(jar, None, (module, name)) 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.")
...@@ -5,29 +5,6 @@ import logging ...@@ -5,29 +5,6 @@ import logging
from re import compile from re import compile
from socket import gethostbyaddr 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 # top-level key handlers
...@@ -228,23 +205,6 @@ def root_handler(config): ...@@ -228,23 +205,6 @@ def root_handler(config):
config.cgi_environment, config.cgi_environment,
config.port_base) 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 # set up trusted proxies
if config.trusted_proxies: if config.trusted_proxies:
import ZPublisher.HTTPRequest import ZPublisher.HTTPRequest
...@@ -264,23 +224,12 @@ def handleConfig(config, multihandler): ...@@ -264,23 +224,12 @@ def handleConfig(config, multihandler):
# DM 2004-11-24: added # DM 2004-11-24: added
def _name2Ips(host, isIp_=compile(r'(\d+\.){3}').match): 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. use *host* itself (as sequence) if it already is an ip address.
Thus, if only a specific interface on a host is trusted, Thus, if only a specific interface on a host is trusted,
identify it by its ip (and not the host name). identify it by its ip (and not the host name).
''' """
if isIp_(host): return [host] if isIp_(host):
return [host]
return gethostbyaddr(host)[2] 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')
...@@ -11,12 +11,6 @@ ...@@ -11,12 +11,6 @@
<import package="tempstorage"/> <import package="tempstorage"/>
<import package="Zope2.Startup" file="warnfilter.xml"/> <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"> <sectiontype name="logger" datatype=".LoggerFactory">
<description> <description>
This "logger" type only applies to access and request ("trace") This "logger" type only applies to access and request ("trace")
...@@ -878,7 +872,6 @@ ...@@ -878,7 +872,6 @@
<metadefault>on</metadefault> <metadefault>on</metadefault>
</key> </key>
<multisection type="server" name="*" attribute="twisted_servers" />
<multisection type="ZServer.server" name="*" attribute="servers"/> <multisection type="ZServer.server" name="*" attribute="servers"/>
<key name="port-base" datatype="integer" default="0"> <key name="port-base" datatype="integer" default="0">
......
...@@ -1005,14 +1005,6 @@ instancehome $INSTANCE ...@@ -1005,14 +1005,6 @@ instancehome $INSTANCE
# user admin # user admin
# password 123 # password 123
# </clock-server> # </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 # Database (zodb_db) section
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment