Author: jmorliaguet
Date: Thu Oct  6 22:09:29 2005
New Revision: 28040

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/controllers/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/cell.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/controllers/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/pageblock.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/slot.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/themepage.py
Log:

- controller / event updates

  added an ObjectModified handler

  => slots can be renamed (modified) and still have a view.



Modified: z3lab/cpsskins/branches/jmo-perspectives/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configure.zcml     (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configure.zcml     Thu Oct  6 
22:09:29 2005
@@ -73,21 +73,4 @@
 
   <include package=".settings" />
 
-
-  <!-- Event subscribers -->
-
-  <subscriber
-    for=".elements.interfaces.IElement
-         zope.app.container.interfaces.IObjectAddedEvent"
-    handler=".controllers.elementAdded"
-    trusted="y"
-  />
-
-  <subscriber
-    for=".elements.interfaces.IElement
-         zope.app.container.interfaces.IObjectRemovedEvent"
-    handler=".controllers.elementRemoved"
-    trusted="y"
-  />
-
 </configure>

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/__init__.py    
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/__init__.py    Thu Oct 
 6 22:09:29 2005
@@ -18,10 +18,30 @@
 __docformat__ = "reStructuredText"
 
 from zope.app.copypastemove import dispatchToSublocations
+from zope.interface import implements
 
 from cpsskins.thememanager import getThemeManager
 from interfaces import IController
 
+class Controller(object):
+    """Event handler
+    """
+    implements(IController)
+
+    def __init__(self, element):
+        self.element = element
+
+    def added(self):
+        """What to do when an element has been added."""
+
+    def removed(self):
+        """What to do when an element has been added."""
+
+    def modified(self):
+        """What to do when an element has been added."""
+
+
+
 # Event handlers
 def elementAdded(element, event):
     """This suscriber is called when an element has been added.
@@ -54,3 +74,11 @@
     # unregister the element
     tmutil.unregisterElement(element)
 
+def elementModified(element, event):
+    """This suscriber is called when an element has been modified.
+    """
+    # get the object's controller
+    controller = IController(element, None)
+    if controller is not None:
+        controller.modified()
+

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/cell.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/cell.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/cell.py        Thu Oct 
 6 22:09:29 2005
@@ -19,18 +19,16 @@
 
 from zope.interface import implements
 
+from cpsskins.controllers import Controller
 from cpsskins.elements.interfaces import IViewable
 from cpsskins.thememanager import getThemeManager
 from interfaces import IController
 
-class CellController:
+class CellController(Controller):
     """Event handler for cells.
-    """ 
+    """
     implements(IController)
 
-    def __init__(self, element):
-        self.element = element
-
     def added(self):
         """What to do when the element has been added.
         """
@@ -41,3 +39,4 @@
         """
         tmutil = getThemeManager()
         tmutil.removeDisplays(self.element)
+

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/configure.zcml 
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/configure.zcml Thu Oct 
 6 22:09:29 2005
@@ -1,6 +1,31 @@
 <configure
     xmlns="http://namespaces.zope.org/zope";>
 
+
+  <!-- Event subscribers -->
+
+  <subscriber
+    for="..elements.interfaces.IElement
+         zope.app.container.interfaces.IObjectAddedEvent"
+    handler=".elementAdded"
+    trusted="y"
+  />
+
+  <subscriber
+    for="..elements.interfaces.IElement
+         zope.app.container.interfaces.IObjectRemovedEvent"
+    handler=".elementRemoved"
+    trusted="y"
+  />
+
+  <subscriber
+    for="..elements.interfaces.IElement
+         zope.app.event.interfaces.IObjectModifiedEvent"
+    handler=".elementModified"
+    trusted="y"
+  />
+
+
   <!-- Theme -->
   <adapter
       factory=".theme.ThemeController"

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/interfaces.py  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/interfaces.py  Thu Oct 
 6 22:09:29 2005
@@ -24,6 +24,9 @@
 
     def added():
         """What to do when the element has been added."""
- 
+
     def removed():
         """What to do when the element has been removed."""
+
+    def modified():
+        """What to do when the element has been modified."""

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/pageblock.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/pageblock.py   
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/pageblock.py   Thu Oct 
 6 22:09:29 2005
@@ -19,18 +19,16 @@
 
 from zope.interface import implements
 
+from cpsskins.controllers import Controller
 from cpsskins.thememanager import getThemeManager
 from cpsskins.elements.interfaces import IViewable
 from interfaces import IController
 
-class PageBlockController:
+class PageBlockController(Controller):
     """Event handler for page blocks
     """ 
     implements(IController)
 
-    def __init__(self, element):
-        self.element = element
-
     def added(self):
         """What to do when the element has been added.
         """
@@ -41,3 +39,4 @@
         """
         tmutil = getThemeManager()
         tmutil.removeDisplays(self.element)
+

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py     Thu Oct 
 6 22:09:29 2005
@@ -20,19 +20,17 @@
 from zope.app.traversing.api import getParent
 from zope.interface import implements
 
+from cpsskins.controllers import Controller
 from cpsskins.elements.interfaces import ICell
 from cpsskins.elements.interfaces import IViewable
 from cpsskins.thememanager import getThemeManager
 from interfaces import IController
 
-class PortletController:
+class PortletController(Controller):
     """Event handler for portlets.
-    """ 
+    """
     implements(IController)
 
-    def __init__(self, element):
-        self.element = element
-
     def added(self):
         """What to do when the element has been added.
         """
@@ -48,3 +46,4 @@
         """
         tmutil = getThemeManager()
         tmutil.removeDisplays(self.element)
+

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/slot.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/slot.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/slot.py        Thu Oct 
 6 22:09:29 2005
@@ -19,18 +19,16 @@
 
 from zope.interface import implements
 
-from cpsskins.elements.interfaces import IViewable
+from cpsskins.controllers import Controller
+from cpsskins.elements.interfaces import IViewable, IDisplayable
 from cpsskins.thememanager import getThemeManager
 from interfaces import IController
 
-class SlotController:
+class SlotController(Controller):
     """Event handler for slots.
     """
     implements(IController)
 
-    def __init__(self, element):
-        self.element = element
-
     def added(self):
         """What to do when the element has been added.
         """
@@ -41,3 +39,9 @@
         """
         tmutil = getThemeManager()
         tmutil.removeDisplays(self.element)
+
+    def modified(self):
+        """What to do when the element has been modified.
+        """
+        if IDisplayable(self.element).getDisplay() is None:
+            IViewable(self.element).addView()

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py       
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py       Thu Oct 
 6 22:09:29 2005
@@ -20,6 +20,7 @@
 from zope.interface import implements
 from zope.component import getUtility
 
+from cpsskins.controllers import Controller
 from cpsskins.configuration.interfaces import IRegistry
 from cpsskins.elements.perspectives import Perspective
 from cpsskins.thememanager import getThemeManager
@@ -27,14 +28,11 @@
 
 storage_registry = getUtility(IRegistry, 'storages')
 
-class ThemeController:
+class ThemeController(Controller):
     """Event handler for themes.
-    """ 
+    """
     implements(IController)
 
-    def __init__(self, element):
-        self.element = element
-
     def added(self):
         """What to do when the element has been added.
         """
@@ -52,7 +50,3 @@
         for id in ('webmail', 'calendar', 'blog'):
             element.addPerspective(Perspective(id))
 
-    def removed(self):
-        """What to do when the element has been removed.
-        """
-        pass

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/themepage.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/themepage.py   
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/themepage.py   Thu Oct 
 6 22:09:29 2005
@@ -19,18 +19,16 @@
 
 from zope.interface import implements
 
+from cpsskins.controllers import Controller
 from cpsskins.elements.interfaces import IViewable
 from cpsskins.thememanager import getThemeManager
 from interfaces import IController
 
-class ThemePageController:
+class ThemePageController(Controller):
     """Event handler for theme pages.
     """
     implements(IController)
 
-    def __init__(self, element):
-        self.element = element
-
     def added(self):
         """What to do when the element has been added.
         """
@@ -46,3 +44,4 @@
         """
         tmutil = getThemeManager()
         tmutil.removeDisplays(self.element)
+
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to