[Checkins] SVN: Products.CMFDefault/branches/2.1/Products/CMFDefault/ - File and Image: Move the call to the underlying OFS rendering to the
Jens Vagelpohl
jens at dataflake.org
Thu May 14 08:52:19 EDT 2009
Log message for revision 99950:
- 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)
(This is a backport of an earlier fix on the trunk)
Changed:
U Products.CMFDefault/branches/2.1/Products/CMFDefault/CHANGES.txt
U Products.CMFDefault/branches/2.1/Products/CMFDefault/File.py
U Products.CMFDefault/branches/2.1/Products/CMFDefault/Image.py
U Products.CMFDefault/branches/2.1/Products/CMFDefault/tests/test_File.py
U Products.CMFDefault/branches/2.1/Products/CMFDefault/tests/test_Image.py
-=-
Modified: Products.CMFDefault/branches/2.1/Products/CMFDefault/CHANGES.txt
===================================================================
--- Products.CMFDefault/branches/2.1/Products/CMFDefault/CHANGES.txt 2009-05-14 12:23:30 UTC (rev 99949)
+++ Products.CMFDefault/branches/2.1/Products/CMFDefault/CHANGES.txt 2009-05-14 12:52:19 UTC (rev 99950)
@@ -4,9 +4,15 @@
2.1.3-beta (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)
+
- skins/zpt_generic/permalink.py: fix typos, wrap object correctly.
See: https://bugs.launchpad.net/bugs/299058 .
+
2.1.2 (2008-09-13)
------------------
Modified: Products.CMFDefault/branches/2.1/Products/CMFDefault/File.py
===================================================================
--- Products.CMFDefault/branches/2.1/Products/CMFDefault/File.py 2009-05-14 12:23:30 UTC (rev 99949)
+++ Products.CMFDefault/branches/2.1/Products/CMFDefault/File.py 2009-05-14 12:52:19 UTC (rev 99950)
@@ -208,8 +208,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.
@@ -218,7 +216,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/branches/2.1/Products/CMFDefault/Image.py
===================================================================
--- Products.CMFDefault/branches/2.1/Products/CMFDefault/Image.py 2009-05-14 12:23:30 UTC (rev 99949)
+++ Products.CMFDefault/branches/2.1/Products/CMFDefault/Image.py 2009-05-14 12:52:19 UTC (rev 99950)
@@ -202,15 +202,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/branches/2.1/Products/CMFDefault/tests/test_File.py
===================================================================
--- Products.CMFDefault/branches/2.1/Products/CMFDefault/tests/test_File.py 2009-05-14 12:23:30 UTC (rev 99949)
+++ Products.CMFDefault/branches/2.1/Products/CMFDefault/tests/test_File.py 2009-05-14 12:52:19 UTC (rev 99950)
@@ -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/branches/2.1/Products/CMFDefault/tests/test_Image.py
===================================================================
--- Products.CMFDefault/branches/2.1/Products/CMFDefault/tests/test_Image.py 2009-05-14 12:23:30 UTC (rev 99949)
+++ Products.CMFDefault/branches/2.1/Products/CMFDefault/tests/test_Image.py 2009-05-14 12:52:19 UTC (rev 99950)
@@ -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