source: products/vendor/Products.CacheSetup/current/Products/CacheSetup/skins/cache_setup/getHeaderSetIdForResource.py @ 3296

Last change on this file since 3296 was 3296, checked in by fenix, 13 years ago

Load Products.CacheSetup?-1.2.1 into vendor/Products.CacheSetup?/current.

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1## Script (Python) "getHeaderSetIdForResource"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=get caching policy for RR-generated CSS, JS, KSS files
9
10from AccessControl import Unauthorized
11
12id = context.getId().lower()
13if id.endswith('.js'):
14    url = context.absolute_url()
15    if url.find('/portal_javascripts/') == -1:
16        return None
17    reg = context.portal_javascripts
18elif id.endswith('.css'):
19    url = context.absolute_url()
20    if url.find('/portal_css/') == -1:
21        return None
22    reg = context.portal_css
23elif id.endswith('.kss'):
24    url = context.absolute_url()
25    if url.find('/portal_kss/') == -1:
26        return None
27    reg = context.portal_kss
28else:
29    return None
30
31try:
32    # XXX workaround for the fact that RR's isCacheable lacks a docstring
33    isCacheable = reg.isCacheable(context.getId())
34except Unauthorized:
35    isCacheable = True
36
37if isCacheable and not reg.getDebugMode():
38    return 'cache-in-browser-forever'
39else:
40    return 'no-cache'
Note: See TracBrowser for help on using the repository browser.