Commit 52bdd068 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

apply caching_policy_manager even if custom render method is used in Web Site or Web Section.

parent 5285a607
...@@ -37,6 +37,7 @@ from AccessControl import Unauthorized ...@@ -37,6 +37,7 @@ from AccessControl import Unauthorized
from OFS.Traversable import NotFound from OFS.Traversable import NotFound
from Persistence import Persistent from Persistence import Persistent
from ZPublisher import BeforeTraverse from ZPublisher import BeforeTraverse
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from Products.ERP5Type.Cache import getReadOnlyTransactionCache from Products.ERP5Type.Cache import getReadOnlyTransactionCache
...@@ -232,7 +233,9 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin): ...@@ -232,7 +233,9 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
if custom_render_method_id is not None: if custom_render_method_id is not None:
if document is None: if document is None:
document = self document = self
return getattr(document, custom_render_method_id)() result = getattr(document, custom_render_method_id)()
_setCacheHeaders(_ViewEmulator().__of__(self), {})
return result
elif document is not None: elif document is not None:
return document() return document()
return Domain.__call__(self) return Domain.__call__(self)
......
...@@ -1143,6 +1143,21 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1143,6 +1143,21 @@ Hé Hé Hé!""", page.asText().strip())
modification_date = rfc1123_date(document.getModificationDate()) modification_date = rfc1123_date(document.getModificationDate())
self.assertEqual(modification_date, last_modified_header) self.assertEqual(modification_date, last_modified_header)
def test_15a_CheckCachingPolicyManager(self):
"""
Check if caching_policy_manager is well applied even if custom
render method is used in Web Site or Web Section.
"""
web_site = self.setupWebSite()
web_section_portal_type = 'Web Section'
web_section = web_site.newContent(portal_type=web_section_portal_type)
self.assertTrue(self.publish(web_site.absolute_url_path()).getHeader('X-Cache-Headers-Set-By'))
web_site.setCustomRenderMethodId('WebSection_viewAsWeb')
self.assertTrue(self.publish(web_site.absolute_url_path()).getHeader('X-Cache-Headers-Set-By'))
self.assertTrue(self.publish(web_section.absolute_url_path()).getHeader('X-Cache-Headers-Set-By'))
web_section.setCustomRenderMethodId('WebSection_viewAsWeb')
self.assertTrue(self.publish(web_section.absolute_url_path()).getHeader('X-Cache-Headers-Set-By'))
def test_16_404ErrorPageIsReturned(self): def test_16_404ErrorPageIsReturned(self):
""" """
Test that when we try to access a non existing url trought a web site, a Test that when we try to access a non existing url trought a web site, a
......
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