Commit 96f4172a authored by Fred Drake's avatar Fred Drake

Remove all uses of environment variables for configuring ZPublisher.

parent efc1aafc
......@@ -12,8 +12,8 @@
##############################################################################
__doc__="""Python Object Publisher -- Publish Python objects on web servers
$Id: Publish.py,v 1.166 2003/11/18 13:17:17 tseaver Exp $"""
__version__='$Revision: 1.166 $'[11:-2]
$Id: Publish.py,v 1.167 2004/04/25 21:26:15 fdrake Exp $"""
__version__='$Revision: 1.167 $'[11:-2]
import sys, os
from Response import Response
......@@ -47,6 +47,17 @@ def missing_name(name, request):
def dont_publish_class(klass, request):
request.response.forbiddenError("class %s" % klass.__name__)
_default_debug_mode = False
_default_realm = None
def set_default_debug_mode(debug_mode):
global _default_debug_mode
_default_debug_mode = debug_mode
def set_default_authentication_realm(realm):
global _default_realm
_default_realm = realm
def publish(request, module_name, after_list, debug=0,
# Optimize:
call_object=call_object,
......@@ -224,10 +235,8 @@ def get_module_info(module_name, modules={},
# Let the app specify a realm
if hasattr(module,'__bobo_realm__'):
realm=module.__bobo_realm__
elif os.environ.has_key('Z_REALM'):
realm=os.environ['Z_REALM']
elif os.environ.has_key('BOBO_REALM'):
realm=os.environ['BOBO_REALM']
elif _default_realm is not None:
realm=_default_realm
else:
realm=module_name
......@@ -236,15 +245,7 @@ def get_module_info(module_name, modules={},
if hasattr(module,'__bobo_debug_mode__'):
debug_mode=not not module.__bobo_debug_mode__
else:
z1 = os.environ.get('Z_DEBUG_MODE','')
z2 = os.environ.get('BOBO_DEBUG_MODE','')
if z1.lower() in ('yes','y') or z1.isdigit():
debug_mode = 1
elif z2.lower() in ('yes','y') or z2.isdigit():
debug_mode = 1
debug_mode = _default_debug_mode
bobo_before = getattr(module, "__bobo_before__", None)
bobo_after = getattr(module, "__bobo_after__", None)
......
......@@ -60,8 +60,11 @@ class ZopeStarter:
"""
def __init__(self):
self.event_logger = logging.getLogger()
# set up our initial logging environment (log everything to stderr
# if we're not in debug mode).
# We log events to the root logger, which is backed by a
# "StartupHandler" log handler. The "StartupHandler" buffers
# log messages. When the "real" loggers are set up, we flush
# accumulated messages in StartupHandler's buffers to the real
# logger.
formatter = logging.Formatter(
"%(asctime)s %(levelname)s %(name)s %(message)s",
"%Y-%m-%d %H:%M:%S")
......@@ -78,14 +81,10 @@ class ZopeStarter:
self.cfg = cfg
def prepare(self):
# we log events to the root logger, which is backed by a
# "StartupHandler" log handler. The "StartupHandler" outputs to
# stderr but also buffers log messages. When the "real" loggers
# are set up, we flush accumulated messages in StartupHandler's
# buffers to the real logger.
self.setupInitialLogging()
self.setupLocale()
self.setupSecurityOptions()
self.setupPublisher()
# Start ZServer servers before we drop privileges so we can bind to
# "low" ports:
self.setupZServerThreads()
......@@ -127,6 +126,13 @@ class ZopeStarter:
def error(self, msg):
logger.error(msg)
def setupPublisher(self):
import Globals
import ZPublisher.Publish
Globals.DevelopmentMode = self.cfg.debug_mode
ZPublisher.Publish.set_default_debug_mode(self.cfg.debug_mode)
ZPublisher.Publish.set_default_realm(self.cfg.http_realm)
def setupSecurityOptions(self):
import AccessControl
AccessControl.setImplementation(
......
......@@ -16,12 +16,6 @@ def _setenv(name, value):
else:
os.environ[name] = `value`
def debug_mode(value):
value and _setenv('Z_DEBUG_MODE', '1')
import Globals
Globals.DevelopmentMode = not not value
return value
def locale(value):
import locale
locale.setlocale(locale.LC_ALL, value)
......@@ -95,10 +89,6 @@ def publisher_profile_file(value):
install_profiling(value)
return value
def http_realm(value):
value is not None and _setenv('Z_REALM', value)
return value
def max_listen_sockets(value):
import ZServer
ZServer.CONNECTION_LIMIT = value
......
......@@ -328,8 +328,7 @@
<metadefault>$clienthome/Z2.lock</metadefault>
</key>
<key name="debug-mode" datatype="boolean" default="on"
handler="debug_mode">
<key name="debug-mode" datatype="boolean" default="on">
<description>
A switch which controls several aspects of Zope operation useful for
developing under Zope. When debug mode is on:
......@@ -486,7 +485,7 @@
</description>
</key>
<key name="http-realm" default="Zope" handler="http_realm">
<key name="http-realm" default="Zope">
<description>
The HTTP "Realm" header value sent by this Zope instance. This value
often shows up in basic authentication dialogs.
......
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