Commit 01e450c1 authored by Aurel's avatar Aurel

CMFCoreUtils: use queryUtility instead of getToolByName to follow the code that is patched

parent 03adae28
...@@ -13,13 +13,14 @@ ...@@ -13,13 +13,14 @@
############################################################################## ##############################################################################
from Acquisition import aq_parent from Acquisition import aq_parent
from Products.CMFCore.utils import getToolByName, SUBTEMPLATE from Products.CMFCore.utils import SUBTEMPLATE
from zope.component import queryUtility
from Products.CMFCore.interfaces import ICachingPolicyManager
# patch _setCacheHeaders so that existing headers are not overridden # patch _setCacheHeaders so that existing headers are not overridden
def _setCacheHeaders(obj, extra_context): def _setCacheHeaders(obj, extra_context):
"""Set cache headers according to cache policy manager for the obj.""" """Set cache headers according to cache policy manager for the obj."""
REQUEST = getattr(obj, 'REQUEST', None) REQUEST = getattr(obj, 'REQUEST', None)
if REQUEST is not None: if REQUEST is not None:
call_count = getattr(REQUEST, SUBTEMPLATE, 1) - 1 call_count = getattr(REQUEST, SUBTEMPLATE, 1) - 1
setattr(REQUEST, SUBTEMPLATE, call_count) setattr(REQUEST, SUBTEMPLATE, call_count)
...@@ -30,7 +31,7 @@ def _setCacheHeaders(obj, extra_context): ...@@ -30,7 +31,7 @@ def _setCacheHeaders(obj, extra_context):
delattr(REQUEST, SUBTEMPLATE) delattr(REQUEST, SUBTEMPLATE)
content = aq_parent(obj) content = aq_parent(obj)
manager = getToolByName(obj, 'caching_policy_manager', None) manager = queryUtility(ICachingPolicyManager)
if manager is None: if manager is None:
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment