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 persistent import Persistent |
13 from persistent import Persistent |
16 from pyramid.events import subscriber |
14 from pyramid.events import subscriber |
17 from zope.container.contained import Contained |
15 from zope.container.contained import Contained |
18 from zope.container.ordered import OrderedContainer |
16 from zope.container.ordered import OrderedContainer |
19 from zope.interface import implementer |
17 from zope.interface import implementer |
20 from zope.lifecycleevent import ObjectModifiedEvent |
18 from zope.lifecycleevent import ObjectModifiedEvent |
21 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent |
19 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, \ |
|
20 IObjectRemovedEvent |
22 from zope.location import locate |
21 from zope.location import locate |
23 from zope.location.interfaces import ISublocations |
22 from zope.location.interfaces import ISublocations |
24 from zope.schema.fieldproperty import FieldProperty |
23 from zope.schema.fieldproperty import FieldProperty |
25 from zope.traversing.interfaces import ITraversable |
24 from zope.traversing.interfaces import ITraversable |
26 |
25 |
27 from pyams_catalog.utils import index_object |
26 from pyams_catalog.utils import index_object |
28 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory |
27 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, \ |
29 from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget, \ |
28 BaseParagraphFactory |
30 IParagraphFactory |
29 from pyams_content.component.paragraph.interfaces import IParagraphContainer, \ |
31 from pyams_content.component.paragraph.interfaces.milestone import IMilestone, IMilestoneContainer, \ |
30 IParagraphContainerTarget, IParagraphFactory |
32 IMilestoneContainerTarget, IMilestoneParagraph, MILESTONE_CONTAINER_KEY, MILESTONE_PARAGRAPH_NAME, \ |
31 from pyams_content.component.paragraph.interfaces.milestone import IMilestone, \ |
33 MILESTONE_PARAGRAPH_RENDERERS, MILESTONE_PARAGRAPH_TYPE |
32 IMilestoneContainer, IMilestoneContainerTarget, IMilestoneParagraph, MILESTONE_CONTAINER_KEY, \ |
|
33 MILESTONE_PARAGRAPH_NAME, MILESTONE_PARAGRAPH_RENDERERS, MILESTONE_PARAGRAPH_TYPE |
34 from pyams_content.features.checker import BaseContentChecker |
34 from pyams_content.features.checker import BaseContentChecker |
35 from pyams_content.features.checker.interfaces import ERROR_VALUE, IContentChecker, MISSING_LANG_VALUE, MISSING_VALUE |
35 from pyams_content.features.checker.interfaces import ERROR_VALUE, IContentChecker, \ |
|
36 MISSING_LANG_VALUE, MISSING_VALUE |
36 from pyams_content.features.renderer import RenderersVocabulary |
37 from pyams_content.features.renderer import RenderersVocabulary |
|
38 from pyams_content.reference.pictograms import IPictogramTable |
37 from pyams_form.interfaces.form import IFormContextPermissionChecker |
39 from pyams_form.interfaces.form import IFormContextPermissionChecker |
38 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator |
40 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator |
39 from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter |
41 from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter |
40 from pyams_utils.factory import factory_config |
42 from pyams_utils.factory import factory_config |
41 from pyams_utils.registry import get_current_registry, get_utility, utility_config |
43 from pyams_utils.registry import get_current_registry, get_utility, utility_config, query_utility |
42 from pyams_utils.request import check_request |
44 from pyams_utils.request import check_request |
43 from pyams_utils.traversing import get_parent |
45 from pyams_utils.traversing import get_parent |
44 from pyams_utils.vocabulary import vocabulary_config |
46 from pyams_utils.vocabulary import vocabulary_config |
|
47 from pyams_utils.zodb import volatile_property |
|
48 |
|
49 |
|
50 __docformat__ = 'restructuredtext' |
45 |
51 |
46 from pyams_content import _ |
52 from pyams_content import _ |
47 |
53 |
48 |
54 |
49 # |
55 # |
55 """Milestone persistent class""" |
61 """Milestone persistent class""" |
56 |
62 |
57 visible = FieldProperty(IMilestone['visible']) |
63 visible = FieldProperty(IMilestone['visible']) |
58 title = FieldProperty(IMilestone['title']) |
64 title = FieldProperty(IMilestone['title']) |
59 label = FieldProperty(IMilestone['label']) |
65 label = FieldProperty(IMilestone['label']) |
|
66 _pictogram_name = FieldProperty(IMilestone['pictogram_name']) |
60 anchor = FieldProperty(IMilestone['anchor']) |
67 anchor = FieldProperty(IMilestone['anchor']) |
|
68 |
|
69 @property |
|
70 def pictogram_name(self): |
|
71 return self._pictogram_name |
|
72 |
|
73 @pictogram_name.setter |
|
74 def pictogram_name(self, value): |
|
75 if value != self._pictogram_name: |
|
76 self._pictogram_name = value |
|
77 del self.pictogram |
|
78 |
|
79 @volatile_property |
|
80 def pictogram(self): |
|
81 table = query_utility(IPictogramTable) |
|
82 if table is not None: |
|
83 return table.get(self._pictogram_name) |
61 |
84 |
62 @property |
85 @property |
63 def target(self): |
86 def target(self): |
64 container = get_parent(self, IParagraphContainer) |
87 container = get_parent(self, IParagraphContainer) |
65 if container is not None: |
88 if container is not None: |