Author: jmorliaguet
Date: Tue Oct 25 00:56:19 2005
New Revision: 28592

Modified:
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/README.txt
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/hello.py
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/configure.zcml
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/text.py
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/configure.zcml
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/items.py
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions.py
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/configure.zcml
Log:

- simplification / API update



Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/README.txt
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/README.txt      (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/README.txt      Tue Oct 25 
00:56:19 2005
@@ -5,7 +5,7 @@
 ========================
 
 :Author: Jean-Marc Orliaguet
-:Version: $Revision: 1 $
+:Version: $Revision: 2 $
 :Copyright: 2005 Nuxeo and Contributors.
 
 .. contents::
@@ -73,52 +73,35 @@
 
 Reserved attributes are:
 
-- identifier (the portlet's identifier)
+- 'identifier' (the portlet's identifier)
 
 You now have a content class for your portlet.
 
-But it still does not display anything, so you will need to register an adapter
-to make the portlet generate some markup.
 
+Step 3: creating the portlet's markup
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Step 3: create the portlet's display data
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The Hello portlet generates some 'Hello world' markup.
 
-The Hello portlet generates 'Hello world', but it is not the portlet's class
-itself that generates the data.
-
-Instead we will use an adapter that implements IDisplayData. 
-
-    >>> from cpsskins.interfaces import IDisplayData
-
-The HelloPortletData adapter will adapt the portlet itself and some context 
info
-object that we will talk about later.
-
-    >>> from cpsskins.interfaces import IContextInfo
-
-At this juncture, simply declare your adapter as adapting IHelloPortlet and
-IContextInfo to IDisplayData
-
-Store the adapted objects, i.e. 'portlet' and 'info' when the adapter is
-constructed, as these may be useful later.
-
-Finally in the adapter's __call__() method, you should prepare the markup
-that the portlet will display and return it.
+In the __call__() method of the portlet, you should prepare and return the
+markup.
 
 Remember that it must be a unicode string.
 
-    >>> class HelloPortletData(object):
-    ...     adapts(IHelloPortlet, IContextInfo)
-    ...     implements(IDisplayData)
+    >>> class HelloPortlet(Portlet):
+    ...     component.implements(IHelloPortlet)
     ...
-    ...     def __init__(self, portlet, info):
-    ...         self.portlet = portlet
-    ...         self.info = info
+    ...     def __init__(self, title=''):
+    ...         self.title = title
     ...
-    ...     def __call__(self, **kw):
+    ...     def __call__(self, info):
     ...         return u"Hello world"
 
 
+An 'info' object is passed as a parameter when the portlet is called.
+This object will be described in example 3.
+
+
 Step 4: registrering the portlet
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -183,27 +166,8 @@
       icon="hello-icon.png"
   />
 
-The last step consists in register the display data adapter:
-
-Since the adapts(IHelloPortlet, IContextInfo') and the
-implements(IDisplayData) have been written inline in the adapter's class, you
-only need to specify the adapter's factory::
-
-  <adapter
-      factory=".hello.HelloPortletData"
-  />
-
-Otherwise you would have written::
-
-  <adapter
-      provides="cpsskins.interfaces.IDisplayData"
-      for=".hello.IHelloPortlet
-           cpsskins.interfaces.IContextInfo"
-      factory=".hello.HelloPortletData"
-  />
 
-
-Step 5: testing the portlet
+Step 4: testing the portlet
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 You can now make sure that your portlet works as expected:
@@ -214,4 +178,5 @@
 
 c) a portlet displaying 'Hello world' will appear on the page!
 
+
 .. footer:: copyright 2005 - Nuxeo and Contributors

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml  (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml  Tue Oct 25 
00:56:19 2005
@@ -16,8 +16,4 @@
       icon="hello-icon.png"
   />
 
-  <adapter
-      factory=".hello.HelloPortletData"
-  />
-
 </configure>

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/hello.py
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/hello.py        (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/hello.py        Tue Oct 25 
00:56:19 2005
@@ -21,7 +21,7 @@
 from zope.interface import implements
 
 from cpsskins import Portlet
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 
 class IHelloPortlet(IPortlet):
     """Interface for the 'hello world' portlet"""
@@ -36,16 +36,6 @@
     def __init__(self, title=''):
         self.title = title
 
-class HelloPortletData(object):
-    """The portlet returns 'Hello world'.
-    """
-    adapts(IHelloPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
-        self.portlet = portlet
-        self.info = info
-
-    def __call__(self, **kw):
+    def __call__(self, info):
         return u"Hello world"
 

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/configure.zcml
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/configure.zcml  (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/configure.zcml  Tue Oct 25 
00:56:19 2005
@@ -16,8 +16,4 @@
       icon="text-icon.png"
   />
 
-  <adapter
-      factory=".text.TextPortletData"
-  />
-
 </configure>

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/text.py
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/text.py (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/text.py Tue Oct 25 00:56:19 2005
@@ -22,7 +22,7 @@
 from zope.schema import Text
 
 from cpsskins import Portlet
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 
 class ITextPortlet(IPortlet):
     """Interface for the Text portlet.
@@ -38,15 +38,5 @@
         self.title = title
         self.text = text
 
-class TextPortletData(object):
-    """The portlet returns the text entered by the user.
-    """
-    adapts(ITextPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
-        self.portlet = portlet
-        self.info = info
-
-    def __call__(self, **kw):
-        return unicode(self.portlet.text) or u"Please enter some text."
+    def __call__(self, info):
+        return unicode(self.text) or u"Please enter some text."

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/configure.zcml
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/configure.zcml  (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/configure.zcml  Tue Oct 25 
00:56:19 2005
@@ -34,8 +34,4 @@
 
   </cpsskins:presentation>
 
-  <adapter
-      factory=".items.ItemsPortletData"
-  />
-
 </configure>

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/items.py
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/items.py        (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/items.py        Tue Oct 25 
00:56:19 2005
@@ -21,7 +21,7 @@
 from zope.interface import implements
 
 from cpsskins import Portlet
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 from cpsskins.model import Items, Item
 
 class IItemsPortlet(IPortlet):
@@ -36,18 +36,7 @@
     def __init__(self, title=''):
         self.title = title
 
-class ItemsPortletData(object):
-    """The portlet creates a list of predefined items.
-
-    The list of items can be used by some widget to produce HTML.
-    """
-    adapts(IItemsPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
-        self.portlet = portlet
-        self.info = info
-
+    def __call__(self, info):
         info.data = Items([
             Item(title=u'first', url='http://www.somesite.com'),
             Item(title=u'second', url='http://www.someothersite.com'),

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions.py
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions.py      (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions.py      Tue Oct 25 
00:56:19 2005
@@ -25,7 +25,7 @@
 
 from cpsskins import Portlet, getContexts
 
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 from cpsskins.model import Items, Item
 
 class IActionsPortlet(IPortlet):
@@ -45,23 +45,14 @@
         self.title = title
         self.category = category
 
-class ActionsPortletData(object):
-    """The portlet creates a list of action items.
-
-    The list of items can be used by some widget to produce HTML.
-    """
-    adapts(IActionsPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
-
+    def __call__(self, info):
         request = info.request
         contexts = getContexts(request)
 
         location = contexts['location']
 
         try:
-           menu = getMenu(portlet.category, location, request)
+           menu = getMenu(self.category, location, request)
         except ComponentLookupError:
            items = []
         else:

Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/configure.zcml
==============================================================================
--- z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/configure.zcml  (original)
+++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/configure.zcml  Tue Oct 25 
00:56:19 2005
@@ -34,8 +34,4 @@
 
   </cpsskins:presentation>
 
-  <adapter
-      factory=".actions.ActionsPortletData"
-  />
-
 </configure>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to