src/pyams_portal/slot.py
changeset 5 670b7956c689
parent 0 6f99128c6d48
child 289 fca4100c1733
--- a/src/pyams_portal/slot.py	Thu Oct 08 12:26:42 2015 +0200
+++ b/src/pyams_portal/slot.py	Mon Jan 18 18:09:46 2016 +0100
@@ -20,29 +20,28 @@
 
 # import packages
 from persistent import Persistent
+from persistent.list import PersistentList
 from zope.container.contained import Contained
 from zope.interface import implementer
 from zope.schema.fieldproperty import FieldProperty
 
 
-PORTAL_SLOTS_KEY = 'pyams_portal.slots'
-
-
 @implementer(ISlotConfiguration)
 class SlotConfiguration(Persistent, Contained):
     """Portal slot class"""
 
     slot_name = FieldProperty(ISlotConfiguration['slot_name'])
+    _portlet_ids = FieldProperty(ISlotConfiguration['portlet_ids'])
     visible = FieldProperty(ISlotConfiguration['visible'])
-    _inherit_parent = FieldProperty(ISlotConfiguration['inherit_parent'])
-    _xs_width = FieldProperty(ISlotConfiguration['xs_width'])
-    _sm_width = FieldProperty(ISlotConfiguration['sm_width'])
-    _md_width = FieldProperty(ISlotConfiguration['md_width'])
-    _lg_width = FieldProperty(ISlotConfiguration['lg_width'])
-    _css_class = FieldProperty(ISlotConfiguration['css_class'])
+    xs_width = FieldProperty(ISlotConfiguration['xs_width'])
+    sm_width = FieldProperty(ISlotConfiguration['sm_width'])
+    md_width = FieldProperty(ISlotConfiguration['md_width'])
+    lg_width = FieldProperty(ISlotConfiguration['lg_width'])
+    css_class = FieldProperty(ISlotConfiguration['css_class'])
 
     def __init__(self, slot_name, **kwargs):
         self.slot_name = slot_name
+        self._portlet_ids = PersistentList()
         self.xs_width = 12
         self.sm_width = 12
         self.md_width = 12
@@ -58,76 +57,17 @@
             return IPortalPage(self.__parent__).template
 
     @property
-    def can_inherit(self):
-        return IPortalPage.providedBy(self.__parent__)
-
-    @property
-    def inherit_parent(self):
-        return self._inherit_parent if self.can_inherit else False
-
-    @inherit_parent.setter
-    def inherit_parent(self, value):
-        self._inherit_parent = value
-
-    @property
-    def xs_width(self):
-        if self.inherit_parent:
-            config = IPortalTemplateConfiguration(self.template)
-            return config.get_slot_configuration(self.slot_name).xs_width
+    def portlet_ids(self):
+        if IPortalTemplate.providedBy(self.__parent__):
+            return self._portlet_ids
         else:
-            return self._xs_width
-        
-    @xs_width.setter
-    def xs_width(self, value):
-        self._xs_width = value
-
-    @property
-    def sm_width(self):
-        if self.inherit_parent:
             config = IPortalTemplateConfiguration(self.template)
-            return config.get_slot_configuration(self.slot_name).sm_width
-        else:
-            return self._sm_width
-        
-    @sm_width.setter
-    def sm_width(self, value):
-        self._sm_width = value
+            return config.get_slot_configuration(self.slot_name).portlet_ids
 
-    @property
-    def md_width(self):
-        if self.inherit_parent:
-            config = IPortalTemplateConfiguration(self.template)
-            return config.get_slot_configuration(self.slot_name).md_width
-        else:
-            return self._md_width
-        
-    @md_width.setter
-    def md_width(self, value):
-        self._md_width = value
-
-    @property
-    def lg_width(self):
-        if self.inherit_parent:
-            config = IPortalTemplateConfiguration(self.template)
-            return config.get_slot_configuration(self.slot_name).lg_width
-        else:
-            return self._lg_width
-        
-    @lg_width.setter
-    def lg_width(self, value):
-        self._lg_width = value
-
-    @property
-    def css_class(self):
-        if self.inherit_parent:
-            config = IPortalTemplateConfiguration(self.template)
-            return config.get_slot_configuration(self.slot_name).css_class
-        else:
-            return self._css_class
-
-    @css_class.setter
-    def css_class(self, value):
-        self._css_class = value
+    @portlet_ids.setter
+    def portlet_ids(self, value):
+        if IPortalTemplate.providedBy(self.__parent__):
+            self._portlet_ids = value
 
     def get_css_class(self, device=None):
         if not device: