|
1 # |
|
2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net> |
|
3 # All Rights Reserved. |
|
4 # |
|
5 # This software is subject to the provisions of the Zope Public License, |
|
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
10 # FOR A PARTICULAR PURPOSE. |
|
11 # |
|
12 |
|
13 from zope.container.ordered import OrderedContainer |
|
14 from zope.interface import implementer |
|
15 from zope.schema.fieldproperty import FieldProperty |
|
16 |
|
17 from pyams_content.component.illustration import IIllustrationTarget, ILinkIllustrationTarget |
|
18 from pyams_content.component.paragraph import IParagraphContainerTarget |
|
19 from pyams_content.component.paragraph.interfaces import IParagraphFactorySettings |
|
20 from pyams_content.component.theme import ITagsTarget, IThemesTarget |
|
21 from pyams_content.component.theme.interfaces import ICollectionsManagerTarget, \ |
|
22 IThemesManagerTarget |
|
23 from pyams_content.features.footer.interfaces import IFooterTarget |
|
24 from pyams_content.features.header.interfaces import IHeaderTarget |
|
25 from pyams_content.features.preview.interfaces import IPreviewTarget |
|
26 from pyams_content.reference.pictograms.interfaces import IPictogramManagerTarget |
|
27 from pyams_content.root.interfaces import ISiteRoot |
|
28 from pyams_content.shared.common.interfaces import ISharedContentFactory |
|
29 from pyams_content.shared.common.manager import BaseSharedTool |
|
30 from pyams_content.shared.common.types import TypedSharedToolMixin |
|
31 from pyams_content.shared.hub.interfaces import IHubManager, IHubManagerFactory |
|
32 from pyams_content.shared.site.container import SiteContainerMixin |
|
33 from pyams_content.shared.site.folder import SiteFolder |
|
34 from pyams_content.shared.site.interfaces import ISiteFolderFactory |
|
35 from pyams_portal.interfaces import IPortalContext |
|
36 from pyams_skin.skin import UserSkinnableContent |
|
37 from pyams_utils.adapter import adapter_config |
|
38 |
|
39 |
|
40 __docformat__ = 'restructuredtext' |
|
41 |
|
42 from pyams_content import _ |
|
43 |
|
44 |
|
45 @implementer(IHubManager, IParagraphFactorySettings, IParagraphContainerTarget, |
|
46 IThemesManagerTarget, ICollectionsManagerTarget, IPictogramManagerTarget, |
|
47 ITagsTarget, IThemesTarget, |
|
48 IIllustrationTarget, ILinkIllustrationTarget, IPortalContext, IHeaderTarget, |
|
49 IFooterTarget, IPreviewTarget) |
|
50 class HubManager(SiteContainerMixin, OrderedContainer, BaseSharedTool, TypedSharedToolMixin, |
|
51 UserSkinnableContent): |
|
52 """Hub manager persistent class""" |
|
53 |
|
54 header = FieldProperty(IHubManager['header']) |
|
55 description = FieldProperty(IHubManager['description']) |
|
56 notepad = FieldProperty(IHubManager['notepad']) |
|
57 |
|
58 allowed_paragraphs = FieldProperty(IParagraphFactorySettings['allowed_paragraphs']) |
|
59 auto_created_paragraphs = FieldProperty(IParagraphFactorySettings['auto_created_paragraphs']) |
|
60 |
|
61 sequence_name = '' # use default sequence generator |
|
62 sequence_prefix = '' |
|
63 |
|
64 content_name = _("Hub manager") |
|
65 |
|
66 @property |
|
67 def folder_factory(self): |
|
68 return ISiteFolderFactory(self, SiteFolder) |
|
69 |
|
70 @property |
|
71 def topic_content_factory(self): |
|
72 return ISharedContentFactory(self, None) |
|
73 |
|
74 @property |
|
75 def topic_content_type(self): |
|
76 factory = self.topic_content_factory |
|
77 if factory is not None: |
|
78 return factory.content_class.content_type |
|
79 |
|
80 def is_deletable(self): |
|
81 for element in self.values(): |
|
82 if not element.is_deletable(): |
|
83 return False |
|
84 return True |
|
85 |
|
86 |
|
87 @adapter_config(context=ISiteRoot, provides=IHubManagerFactory) |
|
88 def site_root_hub_manager_factory(context): |
|
89 return HubManager |
|
90 |
|
91 |
|
92 @adapter_config(context=IHubManager, provides=ISiteFolderFactory) |
|
93 def hub_manager_folder_factory(context): |
|
94 return SiteFolder |