[Checkins] SVN: zope.publisher/trunk/ Merge from 3.4 branch: fixed #98440

Christophe Combelles ccomb at free.fr
Tue Aug 12 20:21:23 EDT 2008


Log message for revision 89767:
  Merge from 3.4 branch: fixed #98440
  

Changed:
  U   zope.publisher/trunk/CHANGES.txt
  U   zope.publisher/trunk/setup.py
  U   zope.publisher/trunk/src/zope/publisher/http.py
  U   zope.publisher/trunk/src/zope/publisher/tests/test_baserequest.py

-=-
Modified: zope.publisher/trunk/CHANGES.txt
===================================================================
--- zope.publisher/trunk/CHANGES.txt	2008-08-13 00:10:07 UTC (rev 89766)
+++ zope.publisher/trunk/CHANGES.txt	2008-08-13 00:21:22 UTC (rev 89767)
@@ -1,11 +1,13 @@
 CHANGES
 =======
 
-3.6.0 (unreleased)
+3.5.4 (unreleased)
 ------------------
 
 Bugs fixed:
 
+* LP #98440: interfaces lost on retried request
+
 * LP #253362: dealing more nicely with malformed HTTP_ACCEPT_CHARSET headers
   within getPreferredCharsets().
 

Modified: zope.publisher/trunk/setup.py
===================================================================
--- zope.publisher/trunk/setup.py	2008-08-13 00:10:07 UTC (rev 89766)
+++ zope.publisher/trunk/setup.py	2008-08-13 00:21:22 UTC (rev 89767)
@@ -24,7 +24,7 @@
 """
 
 setup(name='zope.publisher',
-      version = '3.6.0dev',
+      version = '3.5.4dev',
       url='http://pypi.python.org/pypi/zope.publisher',
       license='ZPL 2.1',
       author='Zope Corporation and Contributors',

Modified: zope.publisher/trunk/src/zope/publisher/http.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/http.py	2008-08-13 00:10:07 UTC (rev 89766)
+++ zope.publisher/trunk/src/zope/publisher/http.py	2008-08-13 00:21:22 UTC (rev 89767)
@@ -437,13 +437,15 @@
         count = getattr(self, '_retry_count', 0)
         self._retry_count = count + 1
 
-        new_response = self.response.retry()
         request = self.__class__(
             # Use the cache stream as the new input stream.
             body_instream=self._body_instream.getCacheStream(),
             environ=self._orig_env,
-            response=new_response,
+            response=self.response.retry(),
             )
+        # restore the interfaces
+        interface.alsoProvides(request, interface.providedBy(self))
+
         request.setPublication(self.publication)
         request._retry_count = self._retry_count
         return request

Modified: zope.publisher/trunk/src/zope/publisher/tests/test_baserequest.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_baserequest.py	2008-08-13 00:10:07 UTC (rev 89766)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_baserequest.py	2008-08-13 00:21:22 UTC (rev 89767)
@@ -27,6 +27,7 @@
      import BaseTestIApplicationRequest
 
 from StringIO import StringIO
+from zope.interface import Interface, providedBy, alsoProvides
 
 class TestBaseRequest(BaseTestIPublicationRequest,
                       BaseTestIApplicationRequest,
@@ -88,7 +89,32 @@
     def test_SetRequestInResponse(self):
         request = self._Test__new()
         self.assertEqual(request.response._request, request)
-        
+
+    def test_retry_keeps_everything(self):
+        """lowlevel test for retry (see #98440)"""
+        # create a retryable request
+        from zope.publisher.browser import TestRequest
+        request = TestRequest()
+        self.assertTrue(request.supportsRetry())
+        # add an interface (this can be a layer)
+        class ISomeInterface(Interface):
+            pass
+        alsoProvides(request, ISomeInterface)
+        # create a retried request
+        retried = request.retry()
+
+        # the requests are not the same
+        self.assertTrue(request is not retried)
+        # the requests have the same attribute list
+        self.assertEqual(dir(request), dir(retried))
+        # the requests have the same interfaces
+        request_interfaces = sorted(list(providedBy(request)))
+        retried_interfaces = sorted(list(providedBy(retried)))
+        self.assertTrue(ISomeInterface.providedBy(retried))
+
+        self.assertEqual(request_interfaces, retried_interfaces)
+
+
 def test_suite():
     return makeSuite(TestBaseRequest)
 



More information about the Checkins mailing list