Author: jmorliaguet
Date: Sat Oct 15 04:41:26 2005
New Revision: 28334

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py
   z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt
   z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/interfaces.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
   z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py
Log:

- replaced portlets' getDisplayData() with __call__()



Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py        
Sat Oct 15 04:41:26 2005
@@ -195,7 +195,7 @@
         data = []
 
         if element.isLeaf():
-            data = element.getDisplayData(info=info)
+            data = element(info=info)
         else:
             for node in element.getChildNodes(info=info):
                 renderer = getMultiAdapter((node, request), IRenderer)

Modified: z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt  Sat Oct 
15 04:41:26 2005
@@ -27,12 +27,12 @@
 1) a portlet has some data to display, called the 'Display Data'.
    it corresponds to the data model in the Model-View-Controller paradigm.
 
-   to obtain the data, the portlet's getDisplayData()' method is called:
+   to obtain the data, the portlet's __call__() method is called:
 
     >>> from cpsskins.model import DisplayData
     >>> from cpsskins.browser.rendering.engine import Context
     >>> info = Context({'request': request})
-    >>> data = portlet.getDisplayData(info)
+    >>> data = portlet(info)
 
    which should return a 'DisplayData' object:
 
@@ -52,7 +52,7 @@
 
     >>> content = data['content']
     >>> content()
-    '<p>Dummy text.</p>'
+    'Dummy text.'
 
 
    the actual content of the display data is either:

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py     Sat Oct 
15 04:41:26 2005
@@ -214,8 +214,8 @@
     def getIdentifier():
         """ """
 
-    def getDisplayData(info):
-        """ """
+    def __call__(info):
+        """Return the data to display."""
 
 class ISlot(ICanvas, IItemContainer):
     """A slot.

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py        Sat Oct 
15 04:41:26 2005
@@ -35,16 +35,17 @@
     >>> portlet
     Portlet('Some portlet')
 
-    >>> portlet.getDisplayData(None)
+    >>> portlet(None)
     Traceback (most recent call last):
     ...
-    NotImplementedError: Portlet needs to override getDisplayData()
+    NotImplementedError: Portlet needs to override __call__()
 
-    >>> def fake_getDisplayData(info):
-    ...     return 'Some data'
+    >>> class SomePortlet:
+    ...     def __call__(self, info):
+    ...         return 'Some data'
 
-    >>> portlet.getDisplayData = fake_getDisplayData
-    >>> portlet.getDisplayData(None)
+    >>> portlet = SomePortlet()
+    >>> portlet(None)
     'Some data'
 
     """
@@ -58,9 +59,9 @@
     def __repr__(self):
         return "Portlet('%s')" % self.title
 
-    def getDisplayData(self, info):
+    def __call__(self, info):
         raise NotImplementedError(
-              "Portlet needs to override getDisplayData()")
+              "Portlet needs to override __call__()")
 
 
 class PortletMover(ObjectMover):

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       
Sat Oct 15 04:41:26 2005
@@ -34,7 +34,7 @@
         self.category = category
         Portlet.__init__(self, **kw)
 
-    def getDisplayData(self, info):
+    def __call__(self, info):
         try:
            menu = getMenu(self.category, info.location, info.request)
         except ComponentLookupError:

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py   
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py   
Sat Oct 15 04:41:26 2005
@@ -33,7 +33,7 @@
     def __init__(self, **kw):
         Portlet.__init__(self, **kw)
 
-    def getDisplayData(self, info):
+    def __call__(self, info):
         url = getMultiAdapter((info.location, info.request), IAbsoluteURL)
         items = [
             Item(

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/interfaces.py 
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/interfaces.py 
Sat Oct 15 04:41:26 2005
@@ -16,6 +16,7 @@
 $Id$
 """
 __docformat__ = "reStructuredText"
+
 from zope.i18nmessageid import MessageFactory
 
 from cpsskins.elements.interfaces import IPortlet
@@ -25,4 +26,3 @@
 class IBreadcrumbsPortlet(IPortlet):
     """Interface for the breadcrumbs portlet"""
 
-    pass

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        
Sat Oct 15 04:41:26 2005
@@ -57,7 +57,7 @@
             markup = html_quote(e)
         return markup
 
-    def getDisplayData(self, info):
+    def __call__(self, info):
         format = self.format
         if format in page_factories:
             page = page_factories[format]()

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 Sat Oct 
15 04:41:26 2005
@@ -47,7 +47,6 @@
         self.text = text
         Portlet.__init__(self, **kw)
 
-    def getDisplayData(self, info):
-        markup = '<p>%s</p>' % self.text
-        return DisplayData(title=self.title, content=HTML(markup))
+    def __call__(self, info):
+        return DisplayData(title=self.title, content=HTML(self.text))
 

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 Sat Oct 
15 04:41:26 2005
@@ -35,7 +35,7 @@
         Portlet.__init__(self, **kw)
         self.link = ''
 
-    def getDisplayData(self, info):
+    def __call__(self, info):
         path = ''
         if self.data:
             path = zapi.getPath(self)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py     
Sat Oct 15 04:41:26 2005
@@ -37,7 +37,7 @@
     def __init__(self, **kw):
         Portlet.__init__(self, **kw)
 
-    def getDisplayData(self, info):
+    def __call__(self, info):
         view, template, request = info.view, info.template, info.request
 
         if view is not None:
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to