Skip to content

Commit

Permalink
Merged 2.10 branch r77227:77228 into 2.9 branch.
Browse files Browse the repository at this point in the history
The REQUEST should not accept holds after it has been closed.
  • Loading branch information
stefanholek committed Jul 2, 2007
1 parent 7f1900c commit 5bbbcb6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Zope Changes

- Collector #1306: Missing acquisition context on local roles screen.

- The REQUEST no longer accepts holds after it has been closed.

- Collector #2153: Supporting unquoted cookies with spaces.

- Collector #2295: Comments in PythonScripts could lead to syntax
Expand Down
3 changes: 2 additions & 1 deletion lib/python/ZPublisher/BaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ def supports_retry(self): return 0
def _hold(self, object):
"""Hold a reference to an object to delay it's destruction until mine
"""
self._held=self._held+(object,)
if self._held is not None:
self._held=self._held+(object,)

def exec_callables(callables):
result = None
Expand Down
11 changes: 11 additions & 0 deletions lib/python/ZPublisher/tests/testBaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ def test_traverse_set_type(self):
self.assertRaises(NotFound, r.traverse, 'folder/simpleSet')
self.assertRaises(NotFound, r.traverse, 'folder/simpleFrozenSet')

def test_hold_after_close(self):
# Request should no longer accept holds after it has been closed
r = self.makeBaseRequest()
r._hold(lambda x: None)
self.assertEqual(len(r._held), 1)
r.close()
# No more holding from now on
self.assertEqual(r._held, None)
r._hold(lambda x: None)
self.assertEqual(r._held, None)


import zope.interface
import zope.component
Expand Down

0 comments on commit 5bbbcb6

Please sign in to comment.