Author: jmorliaguet
Date: Sat Oct 22 15:19:44 2005
New Revision: 28538

Modified:
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/README.txt
   z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml
Log:

- completed example1



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      Sat Oct 22 
15:19:44 2005
@@ -15,7 +15,7 @@
 Steps in developing the Hello portlet
 -------------------------------------
 
-You may take a look the 'hello.py' file while going through the steps.
+You may take a look the `<hello.py>`_ file while going through the steps.
 
 Step 1: defining the portlet's interface (IHelloPortlet)
 ........................................................
@@ -48,23 +48,21 @@
 
 Make your portlet subclass cpsskins.Portlet.
 
-Reserved attributes are:
-
-- identifier (the portlet's identifier)
-
-[TODO: update the list of methods / attributes used by cpsskins.Portlet]
-
     >>> from cpsskins import Portlet
 
-    >>> class HelloPortlet(Portlet):
-    ...     component.implements(IHelloPortlet)
-
 Set the 'title' attribute in the portlet's constructor:
 
+    >>> class HelloPortlet(Portlet):
+    ...     component.implements(IHelloPortlet)
+    ...
     ...     def __init__(self, title=''):
     ...         self.title = title
 
 
+Reserved attributes are:
+
+- 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
@@ -89,24 +87,24 @@
 At this juncture, simply declare your adapter as adapting IHelloPortlet and
 IContextInfo to IDisplayData
 
-    >>> class HelloPortletData(object):
-    ...     adapts(IHelloPortlet, IContextInfo)
-    ...     implements(IDisplayData)
-
 Store the adapted objects, i.e. 'portlet' and 'info' when the adapter is
 constructed, as these may be useful later.
 
-    ...     def __init__(self, portlet, info):
-                self.portlet = portlet
-                self.info = info
-
-Now in the adapter's __call__() method, you should prepare the markup that the
-portlet will display and return it.
+Finally in the adapter's __call__() method, you should prepare the markup
+that the portlet will display and return it.
 
 Remember that it must be a unicode string.
 
-    def __call__(self, **kw):
-        return u"Hello world"
+    >>> class HelloPortletData(object):
+    ...     adapts(IHelloPortlet, IContextInfo)
+    ...     implements(IDisplayData)
+    ...
+    ...     def __init__(self, portlet, info):
+    ...         self.portlet = portlet
+    ...         self.info = info
+    ...
+    ...     def __call__(self, **kw):
+    ...         return u"Hello world"
 
 
 Step 4: registrering the portlet
@@ -115,30 +113,92 @@
 You now have all the components ready to be used. They still need to be
 registered in Zope3. This is done in ZCML using cpsskins directives.
 
-While going through this step, open the 'configure.zcml' file located in this
+While going through this step, open the `<configure.zcml>`_ file located in 
this
 package.
 
 cpsskins provides a set of directives that make it easier to register
 different types of elements such as portlets.
 
-In the header of your ZCML file declare the 'cpsskins' namespace:
+In the header of your ZCML file declare the 'cpsskins' namespace::
 
-<configure
-    xmlns:cpsskins="http://namespaces.zope.org/cpsskins";
-    ...
+  <configure
+      xmlns:cpsskins="http://namespaces.zope.org/cpsskins";
 
 
-Portlets are registered with the 'cpsskins:portlet' directive
+Portlets are registered with the 'cpsskins:portlet' directive::
 
     <cpsskins:portlet
-       ...
+      ...
     />
 
-They have a unique name (a dotted name). For instance in this tutorial
-(ecm.cpsskins) you will give a portlet a name beginning with 'ecm.cpsskins'
+They must have a unique name (a dotted name). For instance in this tutorial
+(ecm.cpsskins) portlet names begin with 'ecm.cpsskins'.
+
+Call your portlet 'ecm.cpsskins.example1' for instance.
+
+You should also give your portlet a title. This title applies to the portlet
+*class* not to portlet *instances*.
+
+Also give a description of what the portlet does::
 
     <cpsskins:portlet
         name="ecm.cpsskins.example1"
-       ...
+        title="Example1: Hello portlet"
+        description="This portlet displays 'Hello world'"
+
+Now register the portlet's factory and the schema interface created earlier::
+
+    (...) 
+        factory=".hello.HelloPortlet"
+        schema=".hello.IHelloPortlet"
+
+Also register an icon for your portlet (16x16 pixels)::
+
+        ...
+        icon="hello-icon.png"
     />
 
+Finally we have::
+
+  <cpsskins:portlet
+      name="ecm.cpsskins.example1"
+      title="Example1: Hello portlet"
+      description="This portlet displays 'hello world'"
+
+      factory=".hello.HelloPortlet"
+      schema=".hello.IHelloPortlet"
+
+      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
+...........................
+
+You can now make sure that your portlet works as expected:
+
+a) open the theme editor ('Page authoring' mode)
+
+b) drag the portlet with the '1' icon onto the canvas
+
+c) a portlet displaying 'Hello world' will appear on the page!
+

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  Sat Oct 22 
15:19:44 2005
@@ -10,7 +10,7 @@
   <cpsskins:portlet
       name="ecm.cpsskins.example1"
       title="Example1: Hello portlet"
-      description="A hello world"
+      description="This portlet displays 'hello world'"
       factory=".hello.HelloPortlet"
       schema=".hello.IHelloPortlet"
       icon="hello-icon.png"
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to