23 IMilestoneContainerTarget, MILESTONE_CONTAINER_KEY, IMilestoneParagraph, MILESTONE_PARAGRAPH_TYPE, \ |
23 IMilestoneContainerTarget, MILESTONE_CONTAINER_KEY, IMilestoneParagraph, MILESTONE_PARAGRAPH_TYPE, \ |
24 MILESTONE_PARAGRAPH_RENDERERS |
24 MILESTONE_PARAGRAPH_RENDERERS |
25 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE |
25 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE |
26 from pyams_form.interfaces.form import IFormContextPermissionChecker |
26 from pyams_form.interfaces.form import IFormContextPermissionChecker |
27 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator |
27 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator |
28 from zope.annotation.interfaces import IAnnotations |
|
29 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent |
28 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent |
30 from zope.location.interfaces import ISublocations |
29 from zope.location.interfaces import ISublocations |
31 from zope.traversing.interfaces import ITraversable |
30 from zope.traversing.interfaces import ITraversable |
32 |
31 |
33 # import interfaces |
32 # import interfaces |
34 from pyams_catalog.utils import index_object |
33 from pyams_catalog.utils import index_object |
35 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory, BaseParagraphContentChecker |
34 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory, BaseParagraphContentChecker |
36 from pyams_content.features.checker import BaseContentChecker |
35 from pyams_content.features.checker import BaseContentChecker |
37 from pyams_content.features.renderer import RenderersVocabulary |
36 from pyams_content.features.renderer import RenderersVocabulary |
38 from pyams_utils.adapter import adapter_config, ContextAdapter |
37 from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter |
39 from pyams_utils.factory import factory_config |
38 from pyams_utils.factory import factory_config |
40 from pyams_utils.registry import get_current_registry, get_utility, utility_config |
39 from pyams_utils.registry import get_current_registry, get_utility, utility_config |
41 from pyams_utils.request import check_request |
40 from pyams_utils.request import check_request |
42 from pyams_utils.traversing import get_parent |
41 from pyams_utils.traversing import get_parent |
43 from pyams_utils.vocabulary import vocabulary_config |
42 from pyams_utils.vocabulary import vocabulary_config |
172 |
171 |
173 |
172 |
174 @adapter_config(context=IMilestoneContainerTarget, provides=IMilestoneContainer) |
173 @adapter_config(context=IMilestoneContainerTarget, provides=IMilestoneContainer) |
175 def milestone_container_factory(target): |
174 def milestone_container_factory(target): |
176 """Milestone container factory""" |
175 """Milestone container factory""" |
177 annotations = IAnnotations(target) |
176 return get_annotation_adapter(target, MILESTONE_CONTAINER_KEY, MilestoneContainer, name='++milestones++') |
178 container = annotations.get(MILESTONE_CONTAINER_KEY) |
|
179 if container is None: |
|
180 container = annotations[MILESTONE_CONTAINER_KEY] = MilestoneContainer() |
|
181 get_current_registry().notify(ObjectCreatedEvent(container)) |
|
182 locate(container, target, '++milestones++') |
|
183 return container |
|
184 |
177 |
185 |
178 |
186 @adapter_config(name='milestones', context=IMilestoneContainerTarget, provides=ITraversable) |
179 @adapter_config(name='milestones', context=IMilestoneContainerTarget, provides=ITraversable) |
187 class MilestoneContainerNamespace(ContextAdapter): |
180 class MilestoneContainerNamespace(ContextAdapter): |
188 """Milestones container ++milestones++ namespace""" |
181 """Milestones container ++milestones++ namespace""" |