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
478ae3a2
Commit
478ae3a2
authored
Sep 03, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate WSGIPublisher from Publish code.
parent
c4241373
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
9 deletions
+65
-9
src/ZPublisher/WSGIPublisher.py
src/ZPublisher/WSGIPublisher.py
+60
-5
src/ZPublisher/tests/test_WSGIPublisher.py
src/ZPublisher/tests/test_WSGIPublisher.py
+1
-1
src/Zope2/Startup/starter.py
src/Zope2/Startup/starter.py
+3
-3
src/Zope2/__init__.py
src/Zope2/__init__.py
+1
-0
No files found.
src/ZPublisher/WSGIPublisher.py
View file @
478ae3a2
...
...
@@ -14,6 +14,7 @@
"""
from
cStringIO
import
StringIO
import
sys
from
thread
import
allocate_lock
import
time
import
transaction
...
...
@@ -30,10 +31,6 @@ from ZPublisher.HTTPRequest import HTTPRequest
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.mapply
import
mapply
from
ZPublisher
import
pubevents
from
ZPublisher.Publish
import
call_object
from
ZPublisher.Publish
import
dont_publish_class
from
ZPublisher.Publish
import
get_module_info
from
ZPublisher.Publish
import
missing_name
from
ZPublisher.Iterators
import
IUnboundStreamIterator
,
IStreamIterator
_NOW
=
None
# overwrite for testing
...
...
@@ -46,6 +43,11 @@ if sys.version_info >= (3, ):
else
:
IOBase
=
file
# NOQA
_DEFAULT_DEBUG_MODE
=
False
_DEFAULT_REALM
=
None
_MODULE_LOCK
=
allocate_lock
()
_MODULES
=
{}
def
_now
():
if
_NOW
is
not
None
:
...
...
@@ -59,6 +61,59 @@ def build_http_date(when):
WEEKDAYNAME
[
wd
],
day
,
MONTHNAME
[
month
],
year
,
hh
,
mm
,
ss
)
def
call_object
(
object
,
args
,
request
):
return
object
(
*
args
)
def
dont_publish_class
(
klass
,
request
):
request
.
response
.
forbiddenError
(
"class %s"
%
klass
.
__name__
)
def
missing_name
(
name
,
request
):
if
name
==
'self'
:
return
request
[
'PARENTS'
][
0
]
request
.
response
.
badRequestError
(
name
)
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
get_module_info
(
module_name
=
'Zope2'
):
global
_MODULES
info
=
_MODULES
.
get
(
module_name
)
if
info
is
not
None
:
return
info
with
_MODULE_LOCK
:
g
=
globals
()
module
=
__import__
(
module_name
,
g
,
g
,
(
'__doc__'
,))
# Let the app specify a realm
realm
=
module_name
if
_DEFAULT_REALM
is
not
None
:
realm
=
_DEFAULT_REALM
app
=
getattr
(
module
,
'bobo_application'
,
module
)
bobo_before
=
getattr
(
module
,
'__bobo_before__'
,
None
)
bobo_after
=
getattr
(
module
,
'__bobo_after__'
,
None
)
error_hook
=
getattr
(
module
,
'zpublisher_exception_hook'
,
None
)
validated_hook
=
getattr
(
module
,
'zpublisher_validated_hook'
,
None
)
transactions_manager
=
module
.
zpublisher_transactions_manager
info
=
(
bobo_before
,
bobo_after
,
app
,
realm
,
_DEFAULT_DEBUG_MODE
,
error_hook
,
validated_hook
,
transactions_manager
)
_MODULES
[
module_name
]
=
info
return
info
class
WSGIResponse
(
HTTPResponse
):
"""A response object for WSGI
...
...
@@ -253,7 +308,7 @@ def publish_module(environ, start_response,
_response_factory
=
WSGIResponse
,
# only for testing
_request_factory
=
HTTPRequest
,
# only for testing
):
module_info
=
get_module_info
(
'Zope2'
)
module_info
=
get_module_info
()
transactions_manager
=
module_info
[
7
]
status
=
200
...
...
src/ZPublisher/tests/test_WSGIPublisher.py
View file @
478ae3a2
...
...
@@ -146,7 +146,7 @@ class TestPublish(unittest.TestCase):
def
_callFUT
(
self
,
request
,
module_info
=
None
):
from
ZPublisher.WSGIPublisher
import
publish
if
module_info
is
None
:
module_info
=
get_module_info
(
'Zope2'
)
module_info
=
get_module_info
()
return
publish
(
request
,
module_info
)
...
...
src/Zope2/Startup/starter.py
View file @
478ae3a2
...
...
@@ -77,9 +77,9 @@ class WSGIStarter(object):
def
setupPublisher
(
self
):
import
ZPublisher.HTTPRequest
import
ZPublisher.Publish
ZPublisher
.
Publish
.
set_default_debug_mode
(
self
.
cfg
.
debug_mode
)
ZPublisher
.
Publish
.
set_default_authentication_realm
(
from
ZPublisher
import
WSGIPublisher
WSGIPublisher
.
set_default_debug_mode
(
self
.
cfg
.
debug_mode
)
WSGIPublisher
.
set_default_authentication_realm
(
self
.
cfg
.
http_realm
)
if
self
.
cfg
.
trusted_proxies
:
mapped
=
[]
...
...
src/Zope2/__init__.py
View file @
478ae3a2
...
...
@@ -71,4 +71,5 @@ bobo_application = None
zpublisher_transactions_manager
=
None
zpublisher_validated_hook
=
None
zpublisher_exception_hook
=
None
__bobo_after__
=
None
__bobo_before__
=
None
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