10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
12 |
12 |
13 __docformat__ = 'restructuredtext' |
13 __docformat__ = 'restructuredtext' |
14 |
14 |
15 |
15 from persistent import Persistent |
16 # import standard library |
16 from zope.container.contained import Contained |
17 |
17 from zope.schema.fieldproperty import FieldProperty |
18 # import interfaces |
|
19 from pyams_content.component.theme.interfaces import \ |
|
20 IPortletThemesSettings, IPortletThemesSettingsTarget, PORTLET_SETTINGS_THEMES_KEY, \ |
|
21 IPortletTagsSettings, IPortletTagsSettingsTarget, PORTLET_SETTINGS_TAGS_KEY, \ |
|
22 IPortletCollectionsSettings, IPortletCollectionsSettingsTarget, PORTLET_SETTINGS_COLLECTIONS_KEY |
|
23 from zope.traversing.interfaces import ITraversable |
18 from zope.traversing.interfaces import ITraversable |
24 |
19 |
25 # import packages |
20 from pyams_content.component.theme.interfaces import IPortletCollectionsSettings, IPortletCollectionsSettingsTarget, \ |
26 from persistent import Persistent |
21 IPortletTagsSettings, IPortletTagsSettingsTarget, IPortletThemesSettings, IPortletThemesSettingsTarget, \ |
27 from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter |
22 PORTLET_SETTINGS_COLLECTIONS_KEY, PORTLET_SETTINGS_TAGS_KEY, PORTLET_SETTINGS_THEMES_KEY |
28 from zope.container.contained import Contained |
23 from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter |
29 from zope.interface import implementer |
24 from pyams_utils.factory import factory_config |
30 from zope.schema.fieldproperty import FieldProperty |
|
31 |
25 |
32 |
26 |
33 # |
27 # |
34 # Portlets tags management |
28 # Portlets tags management |
35 # |
29 # |
36 |
30 |
37 @implementer(IPortletTagsSettings) |
31 @factory_config(IPortletTagsSettings) |
38 class PortletTagsSettings(Persistent, Contained): |
32 class PortletTagsSettings(Persistent, Contained): |
39 """Portlet tags settings""" |
33 """Portlet tags settings""" |
40 |
34 |
41 tags = FieldProperty(IPortletTagsSettings['tags']) |
35 tags = FieldProperty(IPortletTagsSettings['tags']) |
42 |
36 |
43 |
37 |
44 @adapter_config(context=IPortletTagsSettingsTarget, provides=IPortletTagsSettings) |
38 @adapter_config(context=IPortletTagsSettingsTarget, provides=IPortletTagsSettings) |
45 def portlet_tags_settings_factory(context): |
39 def portlet_tags_settings_factory(context): |
46 """Portlet tags settings adapter""" |
40 """Portlet tags settings adapter""" |
47 return get_annotation_adapter(context, PORTLET_SETTINGS_TAGS_KEY, PortletTagsSettings, |
41 return get_annotation_adapter(context, PORTLET_SETTINGS_TAGS_KEY, IPortletTagsSettings, |
48 name='++tags++') |
42 name='++tags++') |
49 |
43 |
50 |
44 |
51 @adapter_config(name='tags', context=IPortletTagsSettingsTarget, provides=ITraversable) |
45 @adapter_config(name='tags', context=IPortletTagsSettingsTarget, provides=ITraversable) |
52 class TagsPortletsSettingsTraverser(ContextAdapter): |
46 class TagsPortletsSettingsTraverser(ContextAdapter): |
58 |
52 |
59 # |
53 # |
60 # Portlets themes management |
54 # Portlets themes management |
61 # |
55 # |
62 |
56 |
63 @implementer(IPortletThemesSettings) |
57 @factory_config(IPortletThemesSettings) |
64 class PortletThemesSettings(Persistent, Contained): |
58 class PortletThemesSettings(Persistent, Contained): |
65 """Portlet themes settings""" |
59 """Portlet themes settings""" |
66 |
60 |
67 themes = FieldProperty(IPortletThemesSettings['themes']) |
61 themes = FieldProperty(IPortletThemesSettings['themes']) |
68 |
62 |
69 |
63 |
70 @adapter_config(context=IPortletThemesSettingsTarget, provides=IPortletThemesSettings) |
64 @adapter_config(context=IPortletThemesSettingsTarget, provides=IPortletThemesSettings) |
71 def portlet_themes_settings_factory(context): |
65 def portlet_themes_settings_factory(context): |
72 """Portlet themes settings adapter""" |
66 """Portlet themes settings adapter""" |
73 return get_annotation_adapter(context, PORTLET_SETTINGS_THEMES_KEY, PortletThemesSettings, |
67 return get_annotation_adapter(context, PORTLET_SETTINGS_THEMES_KEY, IPortletThemesSettings, |
74 name='++themes++') |
68 name='++themes++') |
75 |
69 |
76 |
70 |
77 @adapter_config(name='themes', context=IPortletThemesSettingsTarget, provides=ITraversable) |
71 @adapter_config(name='themes', context=IPortletThemesSettingsTarget, provides=ITraversable) |
78 class ThemesPortletsSettingsTraverser(ContextAdapter): |
72 class ThemesPortletsSettingsTraverser(ContextAdapter): |
84 |
78 |
85 # |
79 # |
86 # Portlets collections management |
80 # Portlets collections management |
87 # |
81 # |
88 |
82 |
89 @implementer(IPortletCollectionsSettings) |
83 @factory_config(IPortletCollectionsSettings) |
90 class PortletCollectionsSettings(Persistent, Contained): |
84 class PortletCollectionsSettings(Persistent, Contained): |
91 """Portlet collections settings""" |
85 """Portlet collections settings""" |
92 |
86 |
93 collections = FieldProperty(IPortletCollectionsSettings['collections']) |
87 collections = FieldProperty(IPortletCollectionsSettings['collections']) |
94 |
88 |
95 |
89 |
96 @adapter_config(context=IPortletCollectionsSettingsTarget, provides=IPortletCollectionsSettings) |
90 @adapter_config(context=IPortletCollectionsSettingsTarget, provides=IPortletCollectionsSettings) |
97 def portlet_collections_settings_factory(context): |
91 def portlet_collections_settings_factory(context): |
98 """Portlet collections settings adapter""" |
92 """Portlet collections settings adapter""" |
99 return get_annotation_adapter(context, PORTLET_SETTINGS_COLLECTIONS_KEY, PortletCollectionsSettings, |
93 return get_annotation_adapter(context, PORTLET_SETTINGS_COLLECTIONS_KEY, IPortletCollectionsSettings, |
100 name='++collections++') |
94 name='++collections++') |
101 |
95 |
102 |
96 |
103 @adapter_config(name='collections', context=IPortletCollectionsSettingsTarget, provides=ITraversable) |
97 @adapter_config(name='collections', context=IPortletCollectionsSettingsTarget, provides=ITraversable) |
104 class CollectionsPortletsSettingsTraverser(ContextAdapter): |
98 class CollectionsPortletsSettingsTraverser(ContextAdapter): |