[Zope-CMF] CMF caching policy manager

Tres Seaver tseaver@zope.com
15 Aug 2002 16:48:56 -0400


On Thu, 2002-08-15 at 14:49, Geoff Davis wrote:
> Hi all--
> 
> The CMF Caching Policy Manager looks potentially quite cool, but I'm a
> little unclear on the best way to use it.  It looks like one somehow needs
> to invoke something like
> 
> response.setHeaders(self.getattr('name_of_caching_policy_manager').getHTTPCa
> chingHeaders(bunch of params here))
> 
> in a page template.  That's kind of ugly, but if placed in a common header
> or macro somewhere, doesn't seem too bad.
> 
> Has anybody actually used the Caching Policy Manager?  Any pointers on good
> practices?  Can anyone enlighten me as to all the params required to set up
> the TALES expressions?  (content, view_method, keywords, time)

FSPageTemplates already do this by default.  Customized ones won't,
which is one reason I have contemplated using a derived-from-ZPT class
for skin methods;  the "stock" ZPTs can be cached, but they use a whole
other mechanism.  Here is what FSPageTemplates do, BTW (inside
pt_render)::

    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 )

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com