[CMF-checkins] CVS: CMF/CMFCore - CachingPolicyManager.py:1.1.2.2 FSPageTemplate.py:1.4.2.1
Tres Seaver
tseaver@zope.com
Wed, 20 Feb 2002 11:35:01 -0500
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv28591
Modified Files:
Tag: tseaver-caching_tool-branch
CachingPolicyManager.py FSPageTemplate.py
Log Message:
- Integrate with FSPageTemplate.
- Fix interface, and test conformance.
=== CMF/CMFCore/CachingPolicyManager.py 1.1.2.1 => 1.1.2.2 ===
#
security.declareProtected( View, 'getHTTPCachingHeaders' )
- def getHTTPCachingHeaders( self, REQUEST, content, view_method, keywords ):
+ def getHTTPCachingHeaders( self, content, view_method, keywords ):
"""
- Update HTTP caching headers in REQUEST based on 'content',
+ Return a list of HTTP caching headers based on 'content',
'view_method', and 'keywords'.
"""
context = createCPContext( content, view_method, keywords )
=== CMF/CMFCore/FSPageTemplate.py 1.4 => 1.4.2.1 ===
from DateTime import DateTime
from DocumentTemplate.DT_Util import html_quote
+from Acquisition import aq_parent
from AccessControl import getSecurityManager, ClassSecurityInfo
from Shared.DC.Scripts.Script import Script
from Products.PageTemplates.PageTemplate import PageTemplate
@@ -27,6 +28,7 @@
from DirectoryView import registerFileExtension, registerMetaType, expandpath
from CMFCorePermissions import ViewManagementScreens, View, FTPAccess
from FSObject import FSObject
+from utils import getToolByName
class FSPageTemplate(FSObject, Script, PageTemplate):
"Wrapper for Page Template"
@@ -108,6 +110,36 @@
self.id, err_type, html_quote(err_msg) )
raise RuntimeError, msg
+ else:
+
+ def pt_render(self, source=0, extra_context={}):
+
+ if not source: # Hook up to caching policy.
+
+ REQUEST = getattr( self, 'REQUEST', None )
+
+ if REQUEST:
+
+ content = aq_parent( self )
+
+ mgr = getToolByName( content
+ , 'caching_policy_manager'
+ , None
+ )
+
+ if mgr:
+ view_name = self.getId()
+ RESPONSE = REQUEST[ 'RESPONSE' ]
+ headers = mgr.getHTTPCachingHeaders( content
+ , view_name
+ , extra_context
+ )
+ for key, value in headers:
+ RESPONSE.setHeader( key, value )
+
+ return FSPageTemplate.inheritedAttribute('pt_render')( self,
+ source, extra_context )
+
# Copy over more mothods
security.declareProtected(FTPAccess, 'manage_FTPget')
security.declareProtected(View, 'get_size')