[Zope-CMF] Re: Caching Policy Manager

Tres Seaver tseaver at zope.com
Mon Apr 26 13:51:10 EDT 2004

Fred Yankowski wrote:
> On Mon, Apr 26, 2004 at 10:02:53AM -0400, Jean-Francois.Doyon at CCRS.NRCan.gc.ca wrote:
>>python: content.meta_type == 'Filesystem Image'
>>python: content.getId() == 'something'
>>etc ...
>>But not matter what, I don't see any headers getting set as I'd
> Deja vu (this subject has arisen several times on the Zope lists and
> always ends up in an inconclusive muddle).
> Anyway, based on my testing and reading of the code, the 'content'
> item available to the predicate in a policy is set to the *parent* of
> the object being considered for cache headers.  Near as I can tell,
> that makes it impossible to have tests like yours that check the
> meta_type of the object itself.  See the _setCacheHeaders() function
> in CMFCore/utils.py, where it sets content to the value of
> aq_parent(obj).

The CPM is designed to set caching policies for *content*;  the 
Filesystem* skin objects are *software*, not *content*.  Here is the 
mapping for the top-level names available to the predicate expression 
(from the docstring in CMFCore/CachingPolicyManager):

     """ Represent a single class of cachable objects:

           - class membership is defined by 'predicate', a TALES expression
             with access to the following top-level names:

             'content' -- the content object itself

             'view' -- the name of the view method

             'keywords' -- keywords passed to the request

             'request' -- the REQUEST object itself

             'member' -- the authenticated member, or None if anonymous

             'modules' -- usual TALES access-with-import

             'nothing' -- None

So, for instance, you could get to the skin object via:

    python:  getattr(content, view)

You could argue that we should make the skin object directly available 
to the expression, e.g. bound to 'template'.

As Dmitry pointed out, you can also associate an FS8 skin object with a 
cache manager via its '*.meatadata' file, by setting the top-level name
'cache' to the ID of the cache manager.

Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com

More information about the Zope-CMF mailing list