[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/ - File and Image: Move the call to the underlying OFS rendering to the
Jens Vagelpohl
jens at dataflake.org
Sun Sep 14 06:12:36 EDT 2008
Log message for revision 91136:
- File and Image: Move the call to the underlying OFS rendering to the
end of their own index_html methods to ensure the caching policy
manager can set headers in all situations.
(https://bugs.launchpad.net/zope-cmf/+bug/161723)
Changed:
U Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt
U Products.CMFDefault/trunk/Products/CMFDefault/File.py
U Products.CMFDefault/trunk/Products/CMFDefault/Image.py
U Products.CMFDefault/trunk/Products/CMFDefault/tests/test_File.py
U Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Image.py
-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt 2008-09-14 09:35:53 UTC (rev 91135)
+++ Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt 2008-09-14 10:12:35 UTC (rev 91136)
@@ -4,6 +4,11 @@
2.2.0 (unreleased)
------------------
+- File and Image: Move the call to the underlying OFS rendering to the
+ end of their own index_html methods to ensure the caching policy
+ manager can set headers in all situations.
+ (https://bugs.launchpad.net/zope-cmf/+bug/161723)
+
- Discussions: Replaced the old (and no longer working) way to force
Discussion Items into published state by default with a real
single-state workflow so they are put into published state correctly.
Modified: Products.CMFDefault/trunk/Products/CMFDefault/File.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/File.py 2008-09-14 09:35:53 UTC (rev 91135)
+++ Products.CMFDefault/trunk/Products/CMFDefault/File.py 2008-09-14 10:12:35 UTC (rev 91136)
@@ -205,8 +205,6 @@
_setCacheHeaders(view, extra_context={})
return ''
- rendered = OFS.Image.File.index_html(self, REQUEST, RESPONSE)
-
# There are 2 Cache Managers which can be in play....
# need to decide which to use to determine where the cache headers
# are decided on.
@@ -215,7 +213,7 @@
else:
_setCacheHeaders(view, extra_context={})
- return rendered
+ return OFS.Image.File.index_html(self, REQUEST, RESPONSE)
def _setOldCacheHeaders(self):
# return False to disable this simple caching behaviour
Modified: Products.CMFDefault/trunk/Products/CMFDefault/Image.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/Image.py 2008-09-14 09:35:53 UTC (rev 91135)
+++ Products.CMFDefault/trunk/Products/CMFDefault/Image.py 2008-09-14 10:12:35 UTC (rev 91136)
@@ -199,15 +199,13 @@
_setCacheHeaders(view, extra_context={})
return ''
- rendered = OFS.Image.Image.index_html(self, REQUEST, RESPONSE)
-
if self.ZCacheable_getManager() is None:
# not none cache manager already taken care of
_setCacheHeaders(view, extra_context={})
else:
self.ZCacheable_set(None)
- return rendered
+ return OFS.Image.Image.index_html(self, REQUEST, RESPONSE)
security.declarePrivate('_setOldCacheHeaders')
def _setOldCacheHeaders(self):
Modified: Products.CMFDefault/trunk/Products/CMFDefault/tests/test_File.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/tests/test_File.py 2008-09-14 09:35:53 UTC (rev 91135)
+++ Products.CMFDefault/trunk/Products/CMFDefault/tests/test_File.py 2008-09-14 10:12:35 UTC (rev 91136)
@@ -156,9 +156,14 @@
, rfc1123_date( mod_time ) )
def test_caching( self ):
+ large_file_data = '0' * 100000
+ def fake_response_write(data):
+ return
+ response_write = self.RESPONSE.write
+ self.RESPONSE.write = fake_response_write
self._setupCachingPolicyManager(DummyCachingManager())
original_len = len(self.RESPONSE.headers)
- file = self._makeOne('test_file', 'test_file.swf')
+ file = self._makeOne('test_file', 'test_file.swf', file=large_file_data)
file = file.__of__(self.root)
file.index_html(self.REQUEST, self.RESPONSE)
headers = self.RESPONSE.headers
@@ -166,6 +171,7 @@
self.failUnless('foo' in headers.keys())
self.failUnless('bar' in headers.keys())
self.assertEqual(headers['test_path'], '/test_file')
+ self.RESPONSE.write = response_write
def test_suite():
Modified: Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Image.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Image.py 2008-09-14 09:35:53 UTC (rev 91135)
+++ Products.CMFDefault/trunk/Products/CMFDefault/tests/test_Image.py 2008-09-14 10:12:35 UTC (rev 91136)
@@ -236,9 +236,14 @@
self.assertEqual( self.RESPONSE.getStatus(), 304 )
def test_caching( self ):
+ large_data = '0' * 100000
+ def fake_response_write(data):
+ return
+ response_write = self.RESPONSE.write
+ self.RESPONSE.write = fake_response_write
self._setupCachingPolicyManager(DummyCachingManager())
original_len = len(self.RESPONSE.headers)
- image = self._makeOne('test_image', 'test_image.jpg')
+ image = self._makeOne('test_image', 'test_image.jpg', file=large_data)
image = image.__of__(self.root)
image.index_html(self.REQUEST, self.RESPONSE)
headers = self.RESPONSE.headers
@@ -246,6 +251,7 @@
self.failUnless('foo' in headers.keys())
self.failUnless('bar' in headers.keys())
self.assertEqual(headers['test_path'], '/test_image')
+ self.RESPONSE.write = response_write
def test_index_html_200_with_cpm( self ):
self._setupCachingPolicyManager(DummyCachingManagerWithPolicy())
More information about the Checkins
mailing list