8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
12 |
12 |
13 __docformat__ = 'restructuredtext' |
|
14 |
|
15 from zope.container.ordered import OrderedContainer |
13 from zope.container.ordered import OrderedContainer |
16 from zope.location import locate |
14 from zope.location import locate |
17 from zope.location.interfaces import ISublocations |
15 from zope.location.interfaces import ISublocations |
18 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary |
16 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary |
19 from zope.traversing.interfaces import ITraversable |
17 from zope.traversing.interfaces import ITraversable |
20 |
18 |
21 from pyams_catalog.utils import index_object |
19 from pyams_catalog.utils import index_object |
22 from pyams_content.component.association.interfaces import ASSOCIATION_CONTAINER_KEY, IAssociationContainer, \ |
20 from pyams_content.component.association.interfaces import ASSOCIATION_CONTAINER_KEY, \ |
23 IAssociationContainerTarget, IAssociationInfo, IAssociationItem |
21 IAssociationContainer, IAssociationContainerTarget, IAssociationInfo, IAssociationItem |
24 from pyams_content.features.checker import BaseContentChecker |
22 from pyams_content.features.checker import BaseContentChecker |
25 from pyams_content.features.checker.interfaces import IContentChecker |
23 from pyams_content.features.checker.interfaces import IContentChecker |
26 from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter |
24 from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter |
27 from pyams_utils.factory import factory_config |
25 from pyams_utils.factory import factory_config |
28 from pyams_utils.registry import get_current_registry |
26 from pyams_utils.registry import get_current_registry |
29 from pyams_utils.traversing import get_parent |
27 from pyams_utils.traversing import get_parent |
30 from pyams_utils.vocabulary import vocabulary_config |
28 from pyams_utils.vocabulary import vocabulary_config |
31 from pyams_zmi.layer import IAdminLayer |
29 from pyams_zmi.layer import IAdminLayer |
|
30 |
|
31 |
|
32 __docformat__ = 'restructuredtext' |
32 |
33 |
33 from pyams_content import _ |
34 from pyams_content import _ |
34 |
35 |
35 |
36 |
36 @factory_config(IAssociationContainer) |
37 @factory_config(IAssociationContainer) |
57 |
58 |
58 |
59 |
59 @adapter_config(context=IAssociationContainerTarget, provides=IAssociationContainer) |
60 @adapter_config(context=IAssociationContainerTarget, provides=IAssociationContainer) |
60 def association_container_factory(target): |
61 def association_container_factory(target): |
61 """Associations container factory""" |
62 """Associations container factory""" |
62 return get_annotation_adapter(target, ASSOCIATION_CONTAINER_KEY, IAssociationContainer, name='++ass++') |
63 return get_annotation_adapter(target, ASSOCIATION_CONTAINER_KEY, IAssociationContainer, |
|
64 name='++ass++') |
63 |
65 |
64 |
66 |
65 @adapter_config(name='ass', context=IAssociationContainerTarget, provides=ITraversable) |
67 @adapter_config(name='ass', context=IAssociationContainerTarget, provides=ITraversable) |
66 class AssociationContainerNamespace(ContextAdapter): |
68 class AssociationContainerNamespace(ContextAdapter): |
67 """Associations container ++ass++ namespace""" |
69 """Associations container ++ass++ namespace""" |
92 registry = request.registry |
94 registry = request.registry |
93 for association in IAssociationContainer(self.context).values(): |
95 for association in IAssociationContainer(self.context).values(): |
94 if not association.visible: |
96 if not association.visible: |
95 continue |
97 continue |
96 info = IAssociationInfo(association) |
98 info = IAssociationInfo(association) |
97 for name, checker in sorted(registry.getAdapters((association, ), IContentChecker), |
99 for name, checker in sorted(registry.getAdapters((association,), IContentChecker), |
98 key=lambda x: x[1].weight): |
100 key=lambda x: x[1].weight): |
99 output.append('- {0} :'.format(info.user_title or |
101 output.append('- {0} :'.format(info.user_title or |
100 '({0})'.format(info.inner_title))) |
102 '({0})'.format(info.inner_title))) |
101 output.append(checker.get_check_output(request)) |
103 output.append(checker.get_check_output(request)) |
102 return output |
104 return output |