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
4b3b0281
Commit
4b3b0281
authored
Sep 03, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove support for repoze.tm2.
parent
2f444231
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
96 deletions
+13
-96
CHANGES.rst
CHANGES.rst
+2
-2
src/ZPublisher/WSGIPublisher.py
src/ZPublisher/WSGIPublisher.py
+8
-48
src/ZPublisher/tests/test_WSGIPublisher.py
src/ZPublisher/tests/test_WSGIPublisher.py
+2
-45
src/ZPublisher/tests/test_pubevents.py
src/ZPublisher/tests/test_pubevents.py
+1
-1
No files found.
CHANGES.rst
View file @
4b3b0281
...
...
@@ -31,6 +31,8 @@ Features Added
Restructuring
+++++++++++++
- Remove support for repoze.tm2.
- Change Testing to use the WSGI publisher for functional and testbrowser
based tests incl. functional doctests. Alternatives are available
in `ZServer.Testing`.
...
...
@@ -165,8 +167,6 @@ Bugs Fixed
Features Added
++++++++++++++
- Make repoze.tm2 optional when using the WSGIPublisher.
- Include waitress as a default WSGI app server.
- Add `egg:Zope2#httpexceptions` WSGI middleware.
...
...
src/ZPublisher/WSGIPublisher.py
View file @
4b3b0281
...
...
@@ -17,7 +17,6 @@ import sys
from
thread
import
allocate_lock
import
time
import
transaction
from
zExceptions
import
(
HTTPOk
,
HTTPRedirection
,
...
...
@@ -197,7 +196,7 @@ class WSGIResponse(HTTPResponse):
raise
NotImplementedError
def
publish
(
request
,
module_info
,
repoze_tm_active
=
False
):
def
publish
(
request
,
module_info
):
(
bobo_before
,
bobo_after
,
object
,
...
...
@@ -231,7 +230,7 @@ def publish(request, module_info, repoze_tm_active=False):
request
[
'PARENTS'
]
=
[
object
]
if
not
repoze_tm_active
and
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
begin
()
object
=
request
.
traverse
(
path
,
validated_hook
=
validated_hook
)
...
...
@@ -261,7 +260,7 @@ def publish(request, module_info, repoze_tm_active=False):
notify
(
pubevents
.
PubBeforeCommit
(
request
))
if
not
repoze_tm_active
and
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
commit
()
notify
(
pubevents
.
PubSuccess
(
request
))
...
...
@@ -274,44 +273,15 @@ def publish(request, module_info, repoze_tm_active=False):
return
response
class
_RequestCloserForTransaction
(
object
):
"""Unconditionally close the request at the end of a transaction.
See transaction.interfaces.ISynchronizer
"""
def
__init__
(
self
):
self
.
requests
=
{}
def
add
(
self
,
txn
,
request
):
assert
txn
not
in
self
.
requests
self
.
requests
[
txn
]
=
request
def
beforeCompletion
(
self
,
txn
):
pass
newTransaction
=
beforeCompletion
def
afterCompletion
(
self
,
txn
):
request
=
self
.
requests
.
pop
(
txn
,
None
)
if
request
is
not
None
:
if
txn
.
status
==
'Committed'
:
notify
(
pubevents
.
PubSuccess
(
request
))
request
.
close
()
_request_closer_for_repoze_tm
=
_RequestCloserForTransaction
()
def
publish_module
(
environ
,
start_response
,
_publish
=
publish
,
# only for testing
_response
=
None
,
_response_factory
=
WSGIResponse
,
_request
=
None
,
_request_factory
=
HTTPRequest
,
module_name
=
'Zope2'
,
_
module_name
=
'Zope2'
,
):
module_info
=
get_module_info
(
module_name
)
module_info
=
get_module_info
(
_
module_name
)
transactions_manager
=
module_info
[
7
]
status
=
200
...
...
@@ -329,26 +299,18 @@ def publish_module(environ, start_response,
else
:
request
=
_request
repoze_tm_active
=
'repoze.tm.active'
in
environ
if
repoze_tm_active
:
# NOTE: registerSynch is a no-op after the first request
transaction
.
manager
.
registerSynch
(
_request_closer_for_repoze_tm
)
txn
=
transaction
.
get
()
_request_closer_for_repoze_tm
.
add
(
txn
,
request
)
setDefaultSkin
(
request
)
try
:
try
:
response
=
_publish
(
request
,
module_info
,
repoze_tm_active
)
response
=
_publish
(
request
,
module_info
)
except
Exception
:
try
:
exc_info
=
sys
.
exc_info
()
notify
(
pubevents
.
PubBeforeAbort
(
request
,
exc_info
,
request
.
supports_retry
()))
if
not
repoze_tm_active
and
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
abort
()
notify
(
pubevents
.
PubFailure
(
...
...
@@ -374,9 +336,7 @@ def publish_module(environ, start_response,
# stdout StringIO, so we put that before the body.
result
=
(
stdout
.
getvalue
(),
response
.
body
)
if
not
repoze_tm_active
:
request
.
close
()
# this aborts the transaction!
stdout
.
close
()
for
func
in
response
.
after_list
:
...
...
src/ZPublisher/tests/test_WSGIPublisher.py
View file @
4b3b0281
...
...
@@ -297,9 +297,8 @@ class TestPublishModule(unittest.TestCase):
self
.
assertEqual
(
status
,
'204 No Content'
)
self
.
assertEqual
(
headers
,
[(
'Content-Length'
,
'0'
)])
self
.
assertEqual
(
kw
,
{})
(
request
,
module_info
,
repoze_tm_active
),
kw
=
_publish
.
_called_with
(
request
,
module_info
),
kw
=
_publish
.
_called_with
self
.
assertTrue
(
isinstance
(
request
,
HTTPRequest
))
self
.
assertEqual
(
repoze_tm_active
,
False
)
self
.
assertEqual
(
kw
,
{})
self
.
assertTrue
(
_response
.
_finalized
)
self
.
assertEqual
(
_after1
.
_called_with
,
((),
{}))
...
...
@@ -403,7 +402,7 @@ class TestPublishModule(unittest.TestCase):
app_iter
=
self
.
_callFUT
(
environ
,
start_response
,
_publish
)
self
.
assertTrue
(
app_iter
is
body
)
def
test_request_closed
_when_tm_middleware_not_active
(
self
):
def
test_request_closed
(
self
):
environ
=
self
.
_makeEnviron
()
start_response
=
DummyCallable
()
_request
=
DummyRequest
()
...
...
@@ -421,48 +420,6 @@ class TestPublishModule(unittest.TestCase):
_request_factory
=
_request_factory
)
self
.
assertTrue
(
_request
.
_closed
)
def
test_request_not_closed_when_tm_middleware_active
(
self
):
import
transaction
from
ZPublisher
import
WSGIPublisher
environ
=
self
.
_makeEnviron
()
environ
[
'repoze.tm.active'
]
=
1
start_response
=
DummyCallable
()
_request
=
DummyRequest
()
_request
.
_closed
=
False
def
_close
():
_request
.
_closed
=
True
_request
.
close
=
_close
def
_request_factory
(
stdin
,
environ
,
response
):
return
_request
_publish
=
DummyCallable
()
_publish
.
_result
=
DummyResponse
()
self
.
_callFUT
(
environ
,
start_response
,
_publish
,
_request_factory
=
_request_factory
)
self
.
assertFalse
(
_request
.
_closed
)
txn
=
transaction
.
get
()
self
.
assertTrue
(
txn
in
WSGIPublisher
.
_request_closer_for_repoze_tm
.
requests
)
txn
.
commit
()
self
.
assertTrue
(
_request
.
_closed
)
self
.
assertFalse
(
txn
in
WSGIPublisher
.
_request_closer_for_repoze_tm
.
requests
)
# try again, but this time raise an exception and abort
_request
.
_closed
=
False
_publish
.
_raise
=
Exception
(
'oops'
)
self
.
assertRaises
(
Exception
,
self
.
_callFUT
,
environ
,
start_response
,
_publish
,
_request_factory
=
_request_factory
)
self
.
assertFalse
(
_request
.
_closed
)
txn
=
transaction
.
get
()
self
.
assertTrue
(
txn
in
WSGIPublisher
.
_request_closer_for_repoze_tm
.
requests
)
txn
.
abort
()
self
.
assertFalse
(
txn
in
WSGIPublisher
.
_request_closer_for_repoze_tm
.
requests
)
self
.
assertTrue
(
_request
.
_closed
)
class
DummyRequest
(
dict
):
_processedInputs
=
False
...
...
src/ZPublisher/tests/test_pubevents.py
View file @
4b3b0281
...
...
@@ -82,7 +82,7 @@ class TestPubEvents(TestCase):
'SERVER_NAME'
:
'localhost'
,
'SERVER_PORT'
:
'localhost'
,
'REQUEST_METHOD'
:
'GET'
,
},
start_response
,
_request
=
request
,
module_name
=
module_name
)
},
start_response
,
_request
=
request
,
_
module_name
=
module_name
)
def
testSuccess
(
self
):
r
=
self
.
request
...
...
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