[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup - handlers.py:1.2.2.9
Fred L. Drake, Jr.
fred@zope.com
Mon, 24 Feb 2003 16:57:00 -0500
Update of /cvs-repository/Zope/lib/python/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv10433/lib/python/Zope/Startup
Modified Files:
Tag: new-install-branch
handlers.py
Log Message:
Change how things get passed around. Avoids some special cases.
=== Zope/lib/python/Zope/Startup/handlers.py 1.2.2.8 => 1.2.2.9 ===
--- Zope/lib/python/Zope/Startup/handlers.py:1.2.2.8 Mon Feb 24 15:21:19 2003
+++ Zope/lib/python/Zope/Startup/handlers.py Mon Feb 24 16:56:29 2003
@@ -98,56 +98,36 @@
# server handlers
-class _RootHandler:
- def __init__(self, options):
- self.options = options
-
- def __call__(self, config):
- """ Mutate the configuration with defaults and perform
- fixups of values that require knowledge about configuration
- values outside of their context. """
-
- # if no servers are defined, create default http server and ftp server
- if not config.servers:
- import ZServer.datatypes
-
- conf = DummyServerConfig(8080)
- http = ZServer.datatypes.HTTPServerFactory(conf)
- config.servers.append(http)
-
- conf = DummyServerConfig(8021)
- ftp = ZServer.datatypes.FTPServerFactory(conf)
- config.servers.append(ftp)
-
- # prepare servers:
- for section in config.servers:
- self.prepare_server(section, config)
-
-
- # set up a default root filestorage if there are no root storages
- # mentioned in the config
- databases = config.databases
-
- _resolver = None
-
- def get_dns_resolver(self, config):
- if self._resolver is None and config.dns_ip_address:
- from ZServer.medusa import resolver
- r = resolver.caching_resolver(config.dns_ip_address)
- self._resolver = r
- return self._resolver
-
- def prepare_server(self, factory, config):
- import ZServer.AccessLogger
- logger = ZServer.AccessLogger.access_logger
- dnsresolver = self.get_dns_resolver(config)
+def root_handler(config):
+ """ Mutate the configuration with defaults and perform
+ fixups of values that require knowledge about configuration
+ values outside of their context. """
+
+ # if no servers are defined, create default http server and ftp server
+ if not config.servers:
+ import ZServer.datatypes
+ config.servers = [
+ ZServer.datatypes.HTTPServerFactory(_DummyServerConfig(80)),
+ ZServer.datatypes.FTPServerFactory(_DummyServerConfig(21)),
+ ]
+
+ # create the DNS resolver:
+ if config.dns_ip_address:
+ from ZServer.medusa import resolver
+ dnsresolver = resolver.caching_resolver(config.dns_ip_address)
+ else:
+ dnsresolver = None
+
+ # prepare servers:
+ for factory in config.servers:
factory.prepare(config.ip_address or '',
- dnsresolver, logger, "Zope",
+ dnsresolver,
+ "Zope",
config.cgi_environment or {},
config.port_base)
-class DummyServerConfig:
+class _DummyServerConfig:
class _Thing:
pass
@@ -159,11 +139,9 @@
self.force_connection_close = 0
-def handleConfig(config, multihandler, options):
+def handleConfig(config, multihandler):
handlers = {}
for name, value in globals().items():
if not name.startswith('_'):
handlers[name] = value
- root_handler = _RootHandler(options)
- handlers['root_handler'] = root_handler
return multihandler(handlers)