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