[Zope-Checkins] SVN: Zope/trunk/ Separate clearing and closing a request.
Martijn Pieters
mj at zopatista.com
Fri Sep 18 16:16:03 EDT 2009
Log message for revision 104360:
Separate clearing and closing a request.
Clearing frees resources, closing also sends out the end-request event. Clones
of the current request need to be cleared, only the actual current request
needs to be closed. Fixes LP #414757.
Changed:
U Zope/trunk/doc/CHANGES.rst
U Zope/trunk/src/ZPublisher/BaseRequest.py
U Zope/trunk/src/ZPublisher/HTTPRequest.py
U Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py
-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst 2009-09-18 19:46:22 UTC (rev 104359)
+++ Zope/trunk/doc/CHANGES.rst 2009-09-18 20:16:03 UTC (rev 104360)
@@ -51,6 +51,8 @@
Bugs Fixed
++++++++++
+- LP #414757: Don't send a request closed event from a cloned request.
+
- LP #418454: FTP server did not work with Python 2.6.X
- Fixed issue with sending text containing ':' from MailHost.
Modified: Zope/trunk/src/ZPublisher/BaseRequest.py
===================================================================
--- Zope/trunk/src/ZPublisher/BaseRequest.py 2009-09-18 19:46:22 UTC (rev 104359)
+++ Zope/trunk/src/ZPublisher/BaseRequest.py 2009-09-18 20:16:03 UTC (rev 104360)
@@ -206,11 +206,14 @@
else: other.update(kw)
self.other=other
- def close(self):
+ def clear(self):
self.other.clear()
- notify(EndRequestEvent(None, self))
self._held=None
+ def close(self):
+ self.clear()
+ notify(EndRequestEvent(None, self))
+
def processInputs(self):
"""Do any input processing that could raise errors
"""
Modified: Zope/trunk/src/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/trunk/src/ZPublisher/HTTPRequest.py 2009-09-18 19:46:22 UTC (rev 104359)
+++ Zope/trunk/src/ZPublisher/HTTPRequest.py 2009-09-18 20:16:03 UTC (rev 104360)
@@ -184,7 +184,7 @@
r.retry_count = self.retry_count
return r
- def close(self):
+ def clear(self):
# Clear all references to the input stream, possibly
# removing tempfiles.
self.stdin = None
@@ -194,7 +194,7 @@
# one. Without this, there's the possibility of memory leaking
# after every request.
self._lazies = {}
- BaseRequest.close(self)
+ BaseRequest.clear(self)
def setServerURL(self, protocol=None, hostname=None, port=None):
""" Set the parts of generated URLs. """
@@ -1171,7 +1171,7 @@
except:
rsp.exception()
if object is None:
- req.close()
+ req.clear()
raise rsp.errmsg, sys.exc_info()[1]
# The traversal machinery may return a "default object"
@@ -1191,7 +1191,7 @@
if name != os.path.split(path)[-1]:
object = req.PARENTS[0]
- req.close()
+ req.clear()
return object
def clone(self):
Modified: Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py
===================================================================
--- Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py 2009-09-18 19:46:22 UTC (rev 104359)
+++ Zope/trunk/src/ZPublisher/tests/testHTTPRequest.py 2009-09-18 20:16:03 UTC (rev 104360)
@@ -975,7 +975,20 @@
clone = request.clone()
self.failUnless(IFoo.providedBy(clone))
+ def test_resolve_url_doesnt_send_endrequestevent(self):
+ import zope.event
+ events = []
+ zope.event.subscribers.append(events.append)
+ request = self._makeOne()
+ request['PARENTS'] = [object()]
+ try:
+ request.resolve_url(request.script + '/')
+ finally:
+ zope.event.subscribers.remove(events.append)
+ self.failIf(len(events),
+ "HTTPRequest.resolve_url should not emit events")
+
TEST_ENVIRON = {
'CONTENT_TYPE': 'multipart/form-data; boundary=12345',
'REQUEST_METHOD': 'POST',
More information about the Zope-Checkins
mailing list