[Zope-Checkins]
SVN: Zope/trunk/lib/python/Zope2/Startup/handlers.py
port missing bits that didnt get merged to the head
Brian Lloyd
brian at zope.com
Wed Mar 16 09:41:13 EST 2005
Log message for revision 29497:
port missing bits that didnt get merged to the head
Changed:
U Zope/trunk/lib/python/Zope2/Startup/handlers.py
-=-
Modified: Zope/trunk/lib/python/Zope2/Startup/handlers.py
===================================================================
--- Zope/trunk/lib/python/Zope2/Startup/handlers.py 2005-03-16 14:37:57 UTC (rev 29496)
+++ Zope/trunk/lib/python/Zope2/Startup/handlers.py 2005-03-16 14:41:12 UTC (rev 29497)
@@ -1,5 +1,7 @@
import os
import sys
+from re import compile
+from socket import gethostbyaddr
# top-level key handlers
@@ -16,6 +18,12 @@
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,6 +103,20 @@
import ZServer
ZServer.LARGE_FILE_THRESHOLD = 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 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
+
def cgi_maxlen(value):
import cgi
cgi.maxlen = value
@@ -154,6 +176,16 @@
config.cgi_environment,
config.port_base)
+ # set up trusted proxies
+ if config.trusted_proxies:
+ import ZPublisher.HTTPRequest
+ # DM 2004-11-24: added host name mapping (such that examples in
+ # conf file really have a chance to work
+ mapped = []
+ for name in config.trusted_proxies: mapped.extend(_name2Ips(name))
+ ZPublisher.HTTPRequest.trusted_proxies = tuple(mapped)
+
+
def handleConfig(config, multihandler):
handlers = {}
for name, value in globals().items():
@@ -161,3 +193,13 @@
handlers[name] = value
return multihandler(handlers)
+# DM 2004-11-24: added
+def _name2Ips(host, isIp_=compile(r'(\d+\.){3}').match):
+ '''map a name *host* to the sequence of its ip addresses;
+ use *host* itself (as sequence) if it already is an ip address.
+ Thus, if only a specific interface on a host is trusted,
+ identify it by its ip (and not the host name).
+ '''
+ if isIp_(host): return [host]
+ return gethostbyaddr(host)[2]
+
More information about the Zope-Checkins
mailing list