Commit b229ea94 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

make caching policy manager effective in view() of any classes.

parent 32d7aa6a
...@@ -39,7 +39,6 @@ from AccessControl import ClassSecurityInfo ...@@ -39,7 +39,6 @@ from AccessControl import ClassSecurityInfo
from Acquisition import aq_base from Acquisition import aq_base
from DocumentTemplate.DT_Util import html_quote from DocumentTemplate.DT_Util import html_quote
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.Utils import fill_args_from_request from Products.ERP5Type.Utils import fill_args_from_request
from Products.ERP5.Document.File import File from Products.ERP5.Document.File import File
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
import tempfile, os import tempfile, os
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Image import Image from Products.ERP5.Document.Image import Image
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
from AccessControl.ZopeGuards import guarded_getattr from AccessControl.ZopeGuards import guarded_getattr
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Document import Document, ConversionError, _MARKER, DEFAULT_CONTENT_TYPE from Products.ERP5.Document.Document import Document, ConversionError, _MARKER, DEFAULT_CONTENT_TYPE
from Products.ERP5.Document.File import File from Products.ERP5.Document.File import File
...@@ -195,10 +194,6 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, ...@@ -195,10 +194,6 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
# text_content is not set, return empty string instead of None # text_content is not set, return empty string instead of None
return original_mime_type, '' return original_mime_type, ''
def __call__(self):
_setCacheHeaders(_ViewEmulator().__of__(self), {})
return Document.__call__(self)
security.declareProtected(Permissions.AccessContentsInformation, 'getContentBaseURL') security.declareProtected(Permissions.AccessContentsInformation, 'getContentBaseURL')
def getContentBaseURL(self): def getContentBaseURL(self):
""" """
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
############################################################################## ##############################################################################
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import _setCacheHeaders, _ViewEmulator
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.Document.Domain import Domain from Products.ERP5.Document.Domain import Domain
from Products.ERP5.mixin.extensible_traversable import DocumentExtensibleTraversableMixin from Products.ERP5.mixin.extensible_traversable import DocumentExtensibleTraversableMixin
...@@ -200,7 +199,6 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin): ...@@ -200,7 +199,6 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
We use REQUEST parameters so that they are reset for every We use REQUEST parameters so that they are reset for every
Web transaction and can be accessed from widgets. Web transaction and can be accessed from widgets.
""" """
_setCacheHeaders(_ViewEmulator().__of__(self), {})
# Register current web site physical path for later URL generation # Register current web site physical path for later URL generation
if self.REQUEST.get(self.web_section_key, MARKER) is MARKER: if self.REQUEST.get(self.web_section_key, MARKER) is MARKER:
self.REQUEST[self.web_section_key] = self.getPhysicalPath() self.REQUEST[self.web_section_key] = self.getPhysicalPath()
......
...@@ -67,11 +67,6 @@ class DownloadableMixin: ...@@ -67,11 +67,6 @@ class DownloadableMixin:
""" """
from Products.ERP5.Document.Document import VALID_TEXT_FORMAT_LIST,\ from Products.ERP5.Document.Document import VALID_TEXT_FORMAT_LIST,\
VALID_IMAGE_FORMAT_LIST VALID_IMAGE_FORMAT_LIST
web_cache_kw = kw.copy()
if format is not _MARKER:
web_cache_kw['format'] = format
_setCacheHeaders(_ViewEmulator().__of__(self), web_cache_kw)
if format is _MARKER and not kw: if format is _MARKER and not kw:
# conversion parameters is mandatory to download the converted content. # conversion parameters is mandatory to download the converted content.
# By default allways return view action. # By default allways return view action.
...@@ -79,6 +74,12 @@ class DownloadableMixin: ...@@ -79,6 +74,12 @@ class DownloadableMixin:
return self.view() return self.view()
if format is _MARKER: if format is _MARKER:
format = None format = None
web_cache_kw = kw.copy()
if format:
web_cache_kw['format'] = format
_setCacheHeaders(_ViewEmulator().__of__(self), web_cache_kw)
if not self.checkConversionFormatPermission(format, **kw): if not self.checkConversionFormatPermission(format, **kw):
raise Forbidden('You are not allowed to get this document in this ' \ raise Forbidden('You are not allowed to get this document in this ' \
'format') 'format')
......
...@@ -51,7 +51,7 @@ from ZopePatch import ERP5PropertyManager ...@@ -51,7 +51,7 @@ from ZopePatch import ERP5PropertyManager
from Products.CMFCore.PortalContent import PortalContent from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName, _setCacheHeaders, _ViewEmulator
from Products.CMFCore.WorkflowCore import ObjectDeleted, ObjectMoved from Products.CMFCore.WorkflowCore import ObjectDeleted, ObjectMoved
from Products.CMFCore.CMFCatalogAware import CMFCatalogAware from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
...@@ -2422,7 +2422,10 @@ class Base( CopyContainer, ...@@ -2422,7 +2422,10 @@ class Base( CopyContainer,
security.declareProtected(Permissions.View, 'view') security.declareProtected(Permissions.View, 'view')
def view(self): def view(self):
"""Returns the default view even if index_html is overridden""" """Returns the default view even if index_html is overridden"""
return self._renderDefaultView('view') result = self._renderDefaultView('view')
# call caching policy manager.
_setCacheHeaders(_ViewEmulator().__of__(self), {})
return result
# Default views - the default security in CMFCore # Default views - the default security in CMFCore
# is View - however, security was not defined on # is View - however, security was not defined on
......
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