Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
70d4c95c
Commit
70d4c95c
authored
Mar 16, 2005
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
port missing bits that didnt get merged to the head
parent
8ce1799d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
lib/python/Zope2/Startup/handlers.py
lib/python/Zope2/Startup/handlers.py
+42
-0
No files found.
lib/python/Zope2/Startup/handlers.py
View file @
70d4c95c
import
os
import
sys
from
re
import
compile
from
socket
import
gethostbyaddr
# top-level key handlers
...
...
@@ -16,6 +18,12 @@ 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,6 +103,20 @@ def large_file_threshold(value):
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 @@ def root_handler(config):
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 @@ def handleConfig(config, multihandler):
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
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment