[Zope-Checkins] SVN: Zope/branches/2.12/ Backport r104360 from trunk: do not emit the request closed event from a request clone

Martijn Pieters mj at zopatista.com
Fri Sep 18 16:26:32 EDT 2009


Log message for revision 104361:
  Backport r104360 from trunk: do not emit the request closed event from a request clone

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/ZPublisher/BaseRequest.py
  U   Zope/branches/2.12/src/ZPublisher/HTTPRequest.py
  U   Zope/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2009-09-18 20:16:03 UTC (rev 104360)
+++ Zope/branches/2.12/doc/CHANGES.rst	2009-09-18 20:26:31 UTC (rev 104361)
@@ -15,7 +15,12 @@
 
   - ZODB3 = 3.9.0
 
+Bugs Fixed
+++++++++++
 
+- LP #414757 (backported from Zope trunk): don't emit a IEndRequestEvent when
+  clearing a cloned request.
+
 Zope 2.12.0 c1 (2009/09/04)
 ---------------------------
 

Modified: Zope/branches/2.12/src/ZPublisher/BaseRequest.py
===================================================================
--- Zope/branches/2.12/src/ZPublisher/BaseRequest.py	2009-09-18 20:16:03 UTC (rev 104360)
+++ Zope/branches/2.12/src/ZPublisher/BaseRequest.py	2009-09-18 20:26:31 UTC (rev 104361)
@@ -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/branches/2.12/src/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/branches/2.12/src/ZPublisher/HTTPRequest.py	2009-09-18 20:16:03 UTC (rev 104360)
+++ Zope/branches/2.12/src/ZPublisher/HTTPRequest.py	2009-09-18 20:26:31 UTC (rev 104361)
@@ -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/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py
===================================================================
--- Zope/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py	2009-09-18 20:16:03 UTC (rev 104360)
+++ Zope/branches/2.12/src/ZPublisher/tests/testHTTPRequest.py	2009-09-18 20:26:31 UTC (rev 104361)
@@ -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