1 | """Cache Policy folder implementation |
---|
2 | |
---|
3 | $Id: $ |
---|
4 | """ |
---|
5 | |
---|
6 | __authors__ = 'Ricardo Newbery <ric@digitalmarbles.com>' |
---|
7 | __docformat__ = 'restructuredtext' |
---|
8 | |
---|
9 | from AccessControl import ClassSecurityInfo |
---|
10 | |
---|
11 | from Products.CMFCore import permissions |
---|
12 | |
---|
13 | from Products.Archetypes.atapi import OrderedBaseFolder |
---|
14 | from Products.Archetypes.atapi import registerType |
---|
15 | |
---|
16 | from Products.CacheSetup.interfaces import ICachePolicy |
---|
17 | from Products.CacheSetup.config import PROJECT_NAME, RULES_ID, HEADERSETS_ID |
---|
18 | from nocatalog import NoCatalog |
---|
19 | |
---|
20 | schema = OrderedBaseFolder.schema.copy() |
---|
21 | schema['id'].widget.ignore_visible_ids=True |
---|
22 | # schema['id'].widget.description="Should not contain spaces, underscores or mixed case. An 'X-Cache-Policy-Id' header with this id will be added." |
---|
23 | |
---|
24 | |
---|
25 | class CachePolicy(NoCatalog, OrderedBaseFolder): |
---|
26 | """A container for cache policies""" |
---|
27 | |
---|
28 | __implements__ = (OrderedBaseFolder.__implements__, ICachePolicy) |
---|
29 | |
---|
30 | security = ClassSecurityInfo() |
---|
31 | archetype_name = 'Cache Policy' |
---|
32 | portal_type = meta_type = 'CachePolicy' |
---|
33 | content_icon = 'cachesetup_tool_icon.gif' |
---|
34 | schema = schema |
---|
35 | global_allow = 0 |
---|
36 | allowed_content_types = ['RuleFolder', 'HeaderSetFolder'] |
---|
37 | |
---|
38 | actions = ( |
---|
39 | {'action': 'string:$object_url', |
---|
40 | 'category': 'object', |
---|
41 | 'id': 'view', |
---|
42 | 'name': 'Cache Policy', |
---|
43 | 'permissions': (permissions.ManagePortal,), |
---|
44 | 'visible': False}, |
---|
45 | ) |
---|
46 | |
---|
47 | aliases = { |
---|
48 | '(Default)': 'cache_policy_config', |
---|
49 | 'view' : 'cache_policy_config', |
---|
50 | 'edit' : 'cache_policy_config' |
---|
51 | } |
---|
52 | |
---|
53 | def at_post_create_script(self): |
---|
54 | self.allowed_content_types = ['RuleFolder', 'HeaderSetFolder'] |
---|
55 | |
---|
56 | self.invokeFactory(id=RULES_ID, type_name='RuleFolder') |
---|
57 | rules = getattr(self, RULES_ID) |
---|
58 | rules.unmarkCreationFlag() |
---|
59 | rules.setTitle('Rules') |
---|
60 | rules.reindexObject() |
---|
61 | |
---|
62 | self.invokeFactory(id=HEADERSETS_ID, type_name='HeaderSetFolder') |
---|
63 | header_sets = getattr(self, HEADERSETS_ID) |
---|
64 | header_sets.unmarkCreationFlag() |
---|
65 | header_sets.setTitle('Headers') |
---|
66 | header_sets.reindexObject() |
---|
67 | |
---|
68 | self.allowed_content_types = [] |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | registerType(CachePolicy, PROJECT_NAME) |
---|