Commit 49c27bce authored by Fred Drake's avatar Fred Drake

remove more clunky initialization; simply using the configuration object and

avoiding the weird handler calls makes the initialization easier to understand
(and therefore maintain)
parent 373e9b26
...@@ -87,7 +87,7 @@ class ZopeStarter: ...@@ -87,7 +87,7 @@ class ZopeStarter:
self.setupPublisher() self.setupPublisher()
# Start ZServer servers before we drop privileges so we can bind to # Start ZServer servers before we drop privileges so we can bind to
# "low" ports: # "low" ports:
self.setupZServerThreads() self.setupZServer()
self.setupServers() self.setupServers()
# drop privileges after setting up servers # drop privileges after setting up servers
self.dropPrivileges() self.dropPrivileges()
...@@ -128,11 +128,18 @@ class ZopeStarter: ...@@ -128,11 +128,18 @@ class ZopeStarter:
def setupPublisher(self): def setupPublisher(self):
import Globals import Globals
import ZPublisher.HTTPRequest
import ZPublisher.Publish import ZPublisher.Publish
Globals.DevelopmentMode = self.cfg.debug_mode Globals.DevelopmentMode = self.cfg.debug_mode
ZPublisher.Publish.set_default_debug_mode(self.cfg.debug_mode) ZPublisher.Publish.set_default_debug_mode(self.cfg.debug_mode)
ZPublisher.Publish.set_default_authentication_realm( ZPublisher.Publish.set_default_authentication_realm(
self.cfg.http_realm) self.cfg.http_realm)
if self.cfg.publisher_profile_file:
filename = self.cfg.publisher_profile_file
ZPublisher.Publish.install_profiling(filename)
if self.cfg.trusted_proxies:
proxies = tuple(self.cfg.trusted_proxies)
ZPublisher.HTTPRequest.trusted_proxies = proxies
def setupSecurityOptions(self): def setupSecurityOptions(self):
import AccessControl import AccessControl
...@@ -172,10 +179,11 @@ class ZopeStarter: ...@@ -172,10 +179,11 @@ class ZopeStarter:
'more\ninformation on locale support.' % locale_id 'more\ninformation on locale support.' % locale_id
) )
def setupZServerThreads(self): def setupZServer(self):
# Increase the number of threads # Increase the number of threads
import ZServer import ZServer
ZServer.setNumberOfThreads(self.cfg.zserver_threads) ZServer.setNumberOfThreads(self.cfg.zserver_threads)
ZServer.CONNECTION_LIMIT = self.cfg.max_listen_sockets
def setupServers(self): def setupServers(self):
socket_err = ( socket_err = (
......
...@@ -83,16 +83,6 @@ def rest_output_encoding(value): ...@@ -83,16 +83,6 @@ def rest_output_encoding(value):
value and _setenv('REST_OUTPUT_ENCODING' , value) value and _setenv('REST_OUTPUT_ENCODING' , value)
return value return value
def publisher_profile_file(value):
value is not None and _setenv('PROFILE_PUBLISHER', value)
from ZPublisher.Publish import install_profiling
install_profiling(value)
return value
def max_listen_sockets(value):
import ZServer
ZServer.CONNECTION_LIMIT = value
# server handlers # server handlers
def root_handler(config): def root_handler(config):
...@@ -145,11 +135,6 @@ def root_handler(config): ...@@ -145,11 +135,6 @@ def root_handler(config):
config.cgi_environment, config.cgi_environment,
config.port_base) config.port_base)
# set up trusted proxies
if config.trusted_proxies:
import ZPublisher.HTTPRequest
ZPublisher.HTTPRequest.trusted_proxies = tuple(config.trusted_proxies)
def handleConfig(config, multihandler): def handleConfig(config, multihandler):
handlers = {} handlers = {}
for name, value in globals().items(): for name, value in globals().items():
......
...@@ -167,7 +167,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase): ...@@ -167,7 +167,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
instancehome <<INSTANCE_HOME>> instancehome <<INSTANCE_HOME>>
zserver-threads 10""") zserver-threads 10""")
starter = self.get_starter(conf) starter = self.get_starter(conf)
starter.setupZServerThreads() starter.setupZServer()
from ZServer.PubCore import _n from ZServer.PubCore import _n
self.assertEqual(_n, 10) self.assertEqual(_n, 10)
......
...@@ -450,7 +450,7 @@ ...@@ -450,7 +450,7 @@
<metadefault>unset</metadefault> <metadefault>unset</metadefault>
</key> </key>
<key name="publisher-profile-file" handler="publisher_profile_file"> <key name="publisher-profile-file">
<description> <description>
Causing this directive to point to a file on the filesystem will Causing this directive to point to a file on the filesystem will
cause Zope's profiling capabilities to be enabled. For more cause Zope's profiling capabilities to be enabled. For more
...@@ -675,7 +675,7 @@ ...@@ -675,7 +675,7 @@
I can't quite figure out how to put it there --> I can't quite figure out how to put it there -->
<key name="max-listen-sockets" datatype="integer" <key name="max-listen-sockets" datatype="integer"
handler="max_listen_sockets" default="1000"> default="1000">
<description> <description>
The maximum number of sockets that ZServer will attempt to open The maximum number of sockets that ZServer will attempt to open
in order to service incoming connections. in order to service incoming connections.
......
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