[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/ Modify the index_html method of images and files so that headers set by a caching policy are done as late as possible, specifically AFTER the OFS index_html method has executed, to ensure that the headers it sets are canonical.

Matthew Wilkes matthew at matthewwilkes.co.uk
Fri Nov 20 15:52:23 EST 2009


Log message for revision 105926:
  Modify the index_html method of images and files so that headers set by a caching policy are done as late as possible, specifically AFTER the OFS index_html method has executed, to ensure that the headers it sets are canonical.

Changed:
  U   Products.CMFDefault/trunk/Products/CMFDefault/File.py
  U   Products.CMFDefault/trunk/Products/CMFDefault/Image.py

-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/File.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/File.py	2009-11-20 20:48:29 UTC (rev 105925)
+++ Products.CMFDefault/trunk/Products/CMFDefault/File.py	2009-11-20 20:52:23 UTC (rev 105926)
@@ -204,15 +204,17 @@
             _setCacheHeaders(view, extra_context={})
             return ''
 
-        # 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.
-        if self.ZCacheable_getManager() is not None:
-            self.ZCacheable_set(None)
-        else:
-            _setCacheHeaders(view, extra_context={})
+        try:
+            return OFS.Image.File.index_html(self, REQUEST, RESPONSE)
+        finally:
+            # 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.
+            if self.ZCacheable_getManager() is not None:
+                self.ZCacheable_set(None)
+            else:
+                _setCacheHeaders(view, extra_context={})
 
-        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	2009-11-20 20:48:29 UTC (rev 105925)
+++ Products.CMFDefault/trunk/Products/CMFDefault/Image.py	2009-11-20 20:52:23 UTC (rev 105926)
@@ -198,14 +198,16 @@
             _setCacheHeaders(view, extra_context={})
             return ''
 
-        if self.ZCacheable_getManager() is None:
-            # not none cache manager already taken care of
-            _setCacheHeaders(view, extra_context={})
-        else:
-            self.ZCacheable_set(None)
+        try:
+            return OFS.Image.Image.index_html(self, REQUEST, RESPONSE)
+        finally:
+            if self.ZCacheable_getManager() is None:
+                # not none cache manager already taken care of
+                _setCacheHeaders(view, extra_context={})
+            else:
+                self.ZCacheable_set(None)
+            
 
-        return OFS.Image.Image.index_html(self, REQUEST, RESPONSE)
-
     security.declarePrivate('_setOldCacheHeaders')
     def _setOldCacheHeaders(self):
         # return False to disable this simple caching behaviour



More information about the checkins mailing list