10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
12 |
12 |
13 __docformat__ = 'restructuredtext' |
13 __docformat__ = 'restructuredtext' |
14 |
14 |
15 |
|
16 # import standard library |
|
17 |
|
18 # import interfaces |
|
19 from pyams_portal.interfaces import IPortalTemplateContainer, IPortalTemplateContainerConfiguration, \ |
|
20 IPortalTemplate, IPortalTemplateConfiguration, IPortalPortletsConfiguration, IPortlet, IPortletConfiguration, \ |
|
21 PORTLETS_CONFIGURATION_KEY, TEMPLATE_CONTAINER_CONFIGURATION_KEY, TEMPLATE_CONFIGURATION_KEY |
|
22 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent |
|
23 from zope.traversing.interfaces import ITraversable |
|
24 |
|
25 # import packages |
|
26 from persistent import Persistent |
15 from persistent import Persistent |
27 from persistent.list import PersistentList |
16 from persistent.list import PersistentList |
28 from persistent.mapping import PersistentMapping |
17 from persistent.mapping import PersistentMapping |
29 from pyams_portal.portlet import PortalPortletsConfiguration |
|
30 from pyams_portal.slot import SlotConfiguration |
|
31 from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter |
|
32 from pyams_utils.registry import get_local_registry, get_utility |
|
33 from pyams_utils.request import check_request |
|
34 from pyams_utils.vocabulary import vocabulary_config |
|
35 from pyramid.events import subscriber |
18 from pyramid.events import subscriber |
36 from pyramid.threadlocal import get_current_registry |
19 from pyramid.threadlocal import get_current_registry |
37 from zope.componentvocabulary.vocabulary import UtilityVocabulary |
20 from zope.componentvocabulary.vocabulary import UtilityVocabulary |
38 from zope.container.contained import Contained |
21 from zope.container.contained import Contained |
39 from zope.container.folder import Folder |
22 from zope.container.folder import Folder |
40 from zope.interface import implementer |
23 from zope.interface import implementer |
|
24 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectRemovedEvent |
41 from zope.location import locate |
25 from zope.location import locate |
42 from zope.schema.fieldproperty import FieldProperty |
26 from zope.schema.fieldproperty import FieldProperty |
43 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm |
27 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary |
|
28 from zope.traversing.interfaces import ITraversable |
44 |
29 |
45 from pyams_portal import _ |
30 from pyams_portal import _ |
|
31 from pyams_portal.interfaces import IPortalPortletsConfiguration, IPortalTemplate, IPortalTemplateConfiguration, \ |
|
32 IPortalTemplateContainer, IPortalTemplateContainerConfiguration, IPortlet, IPortletConfiguration, \ |
|
33 PORTLETS_CONFIGURATION_KEY, TEMPLATE_CONFIGURATION_KEY, TEMPLATE_CONTAINER_CONFIGURATION_KEY |
|
34 from pyams_portal.portlet import PortalPortletsConfiguration |
|
35 from pyams_portal.slot import SlotConfiguration |
|
36 from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter |
|
37 from pyams_utils.registry import get_local_registry, get_utility |
|
38 from pyams_utils.request import check_request |
|
39 from pyams_utils.vocabulary import vocabulary_config |
46 |
40 |
47 |
41 |
48 # |
42 # |
49 # Portal templates container |
43 # Portal templates container |
50 # |
44 # |
158 config.delete_portlet_configuration(self.slot_config[slot_name].portlet_ids) |
152 config.delete_portlet_configuration(self.slot_config[slot_name].portlet_ids) |
159 if slot_name in self.slot_names: |
153 if slot_name in self.slot_names: |
160 self.slot_names.remove(slot_name) |
154 self.slot_names.remove(slot_name) |
161 if slot_name in self.slot_config: |
155 if slot_name in self.slot_config: |
162 del self.slot_config[slot_name] |
156 del self.slot_config[slot_name] |
163 for index in range(row_id, self.rows-1): |
157 for index in range(row_id, self.rows - 1): |
164 self.slot_order[index] = self.slot_order[index+1] |
158 self.slot_order[index] = self.slot_order[index + 1] |
165 if self.rows > 0: |
159 if self.rows > 0: |
166 del self.slot_order[self.rows-1] |
160 del self.slot_order[self.rows - 1] |
167 self.rows -= 1 |
161 self.rows -= 1 |
168 |
162 |
169 # slots management |
163 # slots management |
170 |
164 |
171 @property |
165 @property |
195 def add_slot(self, slot_name, row_id=None): |
189 def add_slot(self, slot_name, row_id=None): |
196 assert slot_name not in self.slot_names |
190 assert slot_name not in self.slot_names |
197 self.slot_names.append(slot_name) |
191 self.slot_names.append(slot_name) |
198 if row_id is None: |
192 if row_id is None: |
199 row_id = 0 |
193 row_id = 0 |
|
194 assert 0 <= row_id < self.rows |
200 # init slots order |
195 # init slots order |
201 if row_id not in self.slot_order: |
196 if row_id not in self.slot_order: |
202 self.slot_order[row_id] = PersistentList() |
197 self.slot_order[row_id] = PersistentList() |
203 self.slot_order[row_id].append(slot_name) |
198 self.slot_order[row_id].append(slot_name) |
204 # init slots configuration |
199 # init slots configuration |