Author: jmorliaguet
Date: Tue Oct 18 09:27:23 2005
New Revision: 28377

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/controllers/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py
Log:

- no need to write Portlet.__init__() when developing portlets

  this is done in the ObjectCreatedEvent(portlet) subscriber



Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py      
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py      
Tue Oct 18 09:27:23 2005
@@ -19,6 +19,7 @@
 
 from zope.app import zapi
 from zope.app.container.browser.contents import Contents
+from zope.app.event.objectevent import ObjectCreatedEvent
 from zope.app.location.traversing import LocationPhysicallyLocatable
 from zope.app.publisher.browser import BrowserView
 from zope.app.session.interfaces import ISession
@@ -26,6 +27,7 @@
 from zope.app.zapi import queryMultiAdapter, getMultiAdapter
 from zope.component import adapts
 from zope.component.interfaces import IFactory
+from zope.event import notify
 from zope.interface import implements
 from zope.security.proxy import removeSecurityProxy
 
@@ -231,6 +233,7 @@
 
         factory = zapi.getUtility(IFactory, type_name)
         content = factory()
+        notify(ObjectCreatedEvent(content))
 
         adding = getMultiAdapter((container, request), INodeAdding)
 

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    Tue Oct 
18 09:27:23 2005
@@ -31,6 +31,9 @@
     def __init__(self, element):
         self.element = element
 
+    def created(self):
+        """What to do when an element has been created."""
+
     def added(self):
         """What to do when an element has been added."""
 
@@ -40,9 +43,13 @@
     def modified(self):
         """What to do when an element has been added."""
 
+# Event handlers
 
+def elementCreated(element, event):
+    controller = IController(element, None)
+    if controller is not None:
+        controller.created()
 
-# Event handlers
 def elementAdded(element, event):
     """This suscriber is called when an element has been added.
     """

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 Tue Oct 
18 09:27:23 2005
@@ -6,6 +6,13 @@
 
   <subscriber
     for="..elements.interfaces.IElement
+         zope.app.event.interfaces.IObjectCreatedEvent"
+    handler=".elementCreated"
+    trusted="y"
+  />
+
+  <subscriber
+    for="..elements.interfaces.IElement
          zope.app.container.interfaces.IObjectAddedEvent"
     handler=".elementAdded"
     trusted="y"

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  Tue Oct 
18 09:27:23 2005
@@ -22,6 +22,9 @@
 class IController(Interface):
     """Controller interface"""
 
+    def created():
+        """What to do when the element has been created."""
+
     def added():
         """What to do when the element has been added."""
 

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     Tue Oct 
18 09:27:23 2005
@@ -31,6 +31,11 @@
     """
     implements(IController)
 
+    def created(self):
+        element = self.element
+        element.setIdentifier(None)
+        element.title = ''
+
     def added(self):
         """What to do when the element has been added.
         """

Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py       
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py       
Tue Oct 18 09:27:23 2005
@@ -41,7 +41,6 @@
     """Actions portlet
     """
     def __init__(self, category='zmi_actions', **kw):
-        Portlet.__init__(self, **kw)
         self.category = category
 
 class ActionsPortletData(object):

Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py        
Tue Oct 18 09:27:23 2005
@@ -61,7 +61,6 @@
     """Custom portlet
     """
     def __init__(self, format='', source=''):
-        Portlet.__init__(self)
         self.format = format
         self.source = source
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py 
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py Tue Oct 
18 09:27:23 2005
@@ -53,7 +53,6 @@
     """
 
     def __init__(self, text='', **kw):
-        Portlet.__init__(self, **kw)
         self.text = text
 
 class DummyPortletData(object):

Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py 
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py Tue Oct 
18 09:27:23 2005
@@ -59,7 +59,6 @@
 
     def __init__(self, link='', **kw):
         ImageFile.__init__(self, **kw)
-        Portlet.__init__(self, **kw)
         self.link = ''
 
 class ImagePortletData(object):
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to