Author: jmorliaguet Date: Sat Oct 22 13:33:30 2005 New Revision: 28531 Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/README.txt z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/hello.py z3lab/z3ecm/trunk/src/ecm/cpsskins/example2/text.py z3lab/z3ecm/trunk/src/ecm/cpsskins/example3/items.py Log:
- doc update - portlets return unicode 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 13:33:30 2005 @@ -65,10 +65,45 @@ ... self.title = title -You now have a portlet content class but it still does not display anything. +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: create the portlet's display data ......................................... -TODO +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 + + >>> 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. + +Remember that it must be a unicode string. + + def __call__(self, **kw): + return u"Hello world" 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 Sat Oct 22 13:33:30 2005 @@ -46,5 +46,5 @@ pass def __call__(self, **kw): - return 'Hello world' + return u"Hello world" 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 Sat Oct 22 13:33:30 2005 @@ -49,4 +49,4 @@ self.info = info def __call__(self, **kw): - return self.portlet.text or 'Please enter some text.' + return unicode(self.portlet.text) or u"Please enter some text." 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 Sat Oct 22 13:33:30 2005 @@ -49,6 +49,6 @@ self.info = info info.data = Items([ - Item(title='first', url='http://www.somesite.com'), - Item(title='second', url='http://www.someothersite.com'), + Item(title=u'first', url='http://www.somesite.com'), + Item(title=u'second', url='http://www.someothersite.com'), ]) -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins