Author: jmorliaguet
Date: Tue Oct 25 00:42:15 2005
New Revision: 28590

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py
   z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py
   z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt
   z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml
Log:

- portlets return the markup in __call__(), 'info' is passed as a parameter.



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        
Tue Oct 25 00:42:15 2005
@@ -27,7 +27,7 @@
 
 from cpsskins import getThemeManager, getContexts
 from cpsskins.browser.negociation.interfaces import INegociation
-from cpsskins.browser.rendering.interfaces import IDisplayData, IUpdateData
+from cpsskins.browser.rendering.interfaces import IUpdateData
 from cpsskins.configuration.interfaces import IRegistry
 from cpsskins.elements.interfaces import IElement, ILeaf, ISlot, IDisplayable
 from cpsskins.elements.interfaces import IType
@@ -216,9 +216,8 @@
         rendered = []
         if ILeaf.providedBy(element):
             # do the actual rendering
-            display_data = getMultiAdapter((element, info), IDisplayData)
-            if callable(display_data):
-                rendered.append(display_data(**kw))
+            portlet_markup = element(info, **kw) or ''
+            rendered.append(portlet_markup)
         else:
             for node in element_info['children']:
                 renderer = getMultiAdapter((node, request), IRenderer)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py    
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py    
Tue Oct 25 00:42:15 2005
@@ -43,9 +43,6 @@
     """Hook adapter interface to give leaf elements such as portlets a chance
     to update their data before rendering it."""
 
-class IDisplayData(Interface):
-    """Information used by filters for generating some output to display."""
-
 class IStylesheetRenderer(IRenderer):
     """Render a theme's stylesheets."""
 

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py
    Tue Oct 25 00:42:15 2005
@@ -31,7 +31,6 @@
 from zope.interface import classImplements, Interface, alsoProvides
 
 from cpsskins import browser
-from cpsskins.interfaces import IContextInfo, IDisplayData
 
 browser_path = os.path.dirname(browser.__file__)
 

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  Tue Oct 
25 00:42:15 2005
@@ -30,11 +30,9 @@
    to obtain the data, the portlet's __call__() method is called:
 
     >>> from cpsskins.browser.rendering.engine import ContextInfo
-    >>> from cpsskins.browser.rendering.interfaces import IDisplayData
     >>> info = ContextInfo({'request': request, 'data': None, 'metadata': 
None})
-    >>> data = getMultiAdapter((portlet, info), IDisplayData)
 
-    >>> data()
+    >>> portlet(info=info)
     u'Dummy text.'
 
 
@@ -90,11 +88,11 @@
 
     >>> ztapi.provideAdapter((IWidget, IRequest), IFilter, WidgetFilter)
 
-    >>> def test_render(widget, rendered, data):
+    >>> def test_render(widget, rendered, info):
     ...    widget_filter = getMultiAdapter((widget, request), IFilter)
     ...    return widget_filter(rendered, info)
 
-    >>> test_render(widget, rendered, data)
+    >>> test_render(widget, rendered, info)
     '<div><h1>Test of HTML</h1></div>'
 
 Available widgets:

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     Tue Oct 
25 00:42:15 2005
@@ -181,6 +181,9 @@
         title=_("Portlet's title"),
         required=False)
 
+    def __call__(info):
+        """Return the portlet's data to display"""
+
 class ISlot(ICanvas, IItemContainer):
     """A slot.
     """

Modified: z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      Tue Oct 25 
00:42:15 2005
@@ -22,7 +22,6 @@
 from zope.i18nmessageid import MessageFactory
 
 from cpsskins.elements.interfaces import IPortlet
-from cpsskins.browser.rendering.interfaces import IContextInfo, IDisplayData
 
 _ = MessageFactory("cpsskins")
 

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 25 00:42:15 2005
@@ -26,7 +26,7 @@
 from zope.i18nmessageid import MessageFactory
 
 from cpsskins import Portlet, getContexts
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 from cpsskins.model import Items, Item
 
 _ = MessageFactory("cpsskins")
@@ -47,17 +47,12 @@
         self.title = title
         self.category = category
 
-class ActionsPortletData(object):
-    """The actions portlet's display data
-    """
-    adapts(IActionsPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
+    def __call__(self, info, **kw):
         request = info.request
         contexts = getContexts(request)
+
         try:
-           menu = getMenu(portlet.category, contexts['location'], request)
+           menu = getMenu(self.category, contexts['location'], request)
         except ComponentLookupError:
            items = []
         else:
@@ -70,3 +65,4 @@
                for ac in menu]
 
         info.data = items
+

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml    
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml    
Tue Oct 25 00:42:15 2005
@@ -16,10 +16,6 @@
       icon="actions-icon.png"
   />
 
-  <zope:adapter
-      factory=".ActionsPortletData"
-  />
-
   <presentation
       for=".IActionsPortlet">
 

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   
Tue Oct 25 00:42:15 2005
@@ -23,7 +23,7 @@
 from zope.i18nmessageid import MessageFactory
 
 from cpsskins import Portlet
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 from cpsskins.model import Items, Item
 
 _ = MessageFactory("cpsskins")
@@ -39,15 +39,10 @@
     def __init__(self, title=''):
         self.title = title
 
-class BreadcrumbsPortletData(object):
-    """The breadcrumbs portlet's display data
-    """
-    adapts(IBreadcrumbsPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
+    def __call__(self, info, **kw):
         request = info.request
         contexts = request.annotations['cpsskins.contexts']
+
         url = getMultiAdapter((contexts['location'], request), IAbsoluteURL)
         items = [
             Item(title=bc['name'], url=bc['url'])

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml    
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml    
    Tue Oct 25 00:42:15 2005
@@ -16,10 +16,6 @@
       icon="breadcrumbs-icon.png"
   />
 
-  <zope:adapter
-      factory=".BreadcrumbsPortletData"
-  />
-
   <!-- The portlet's presentation -->
 
   <presentation

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 25 00:42:15 2005
@@ -29,7 +29,7 @@
 from zope.schema.vocabulary import SimpleVocabulary
 
 from cpsskins import Portlet, getContexts
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 
 _ = MessageFactory("cpsskins")
 
@@ -68,28 +68,15 @@
         self.format = format
         self.source = source
 
-class CustomPortletData(object):
-    """The custom portlet's display data
-    """
-    adapts(ICustomPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
-        self.portlet = portlet
-        self.info = info
-
-    def __call__(self, **kw):
-        info = self.info
-        portlet = self.portlet
-
+    def __call__(self, info, **kw):
         request = info.request
         contexts = getContexts(request)
 
-        format = portlet.format
+        format = self.format
         if format in page_factories:
             page = page_factories[format]()
             page = contained(page, contexts['location'])
-            page.setSource(portlet.source)
+            page.setSource(self.source)
             markup = unicode(_renderPage(page, request))
         else:
             markup = _("Page not configured.")

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml     
Tue Oct 25 00:42:15 2005
@@ -16,9 +16,6 @@
       icon="custom-icon.png"
   />
 
-  <zope:adapter
-      factory=".CustomPortletData"
-  />
 
   <!-- The portlet's presentation -->
 

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 
25 00:42:15 2005
@@ -23,7 +23,7 @@
 from zope.i18nmessageid import MessageFactory
 
 from cpsskins import Portlet
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 
 _ = MessageFactory("cpsskins")
 
@@ -39,20 +39,10 @@
     """
     implements(IDummyPortlet)
 
-    def __init__(self, title='', text='', **kw):
+    def __init__(self, title='', text=''):
         self.title = title
         self.text = text
 
-class DummyPortletData(object):
-    """The dummy portlet's display data
-    """
-    adapts(IDummyPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
-        self.portlet = portlet
-        self.info = info
-
-    def __call__(self, **kw):
-        return unicode(self.portlet.text) or _("No text available")
+    def __call__(self, info, **kw):
+        return unicode(self.text) or _("No text available")
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml      
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml      
Tue Oct 25 00:42:15 2005
@@ -16,10 +16,6 @@
       icon="dummy-icon.png"
   />
 
-  <zope:adapter
-      factory=".DummyPortletData"
-  />
-
   <!-- The portlet's presentation -->
 
   <presentation

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 
25 00:42:15 2005
@@ -26,7 +26,7 @@
 from zope.i18nmessageid import MessageFactory
 
 from cpsskins import Portlet
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 from cpsskins.model import Image
 
 _ = MessageFactory("cpsskins")
@@ -64,17 +64,11 @@
         self.link = ''
         ImageFile.__init__(self, **kw)
 
-class ImagePortletData(object):
-    """The image portlet's display data
-    """
-    adapts(IImagePortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
+    def __call__(self, info, **kw):
         path = ''
-        if portlet.data:
-            path = zapi.getPath(portlet)
+        if self.data:
+            path = zapi.getPath(self)
 
         info.data = Image(path=path)
-        info.metadata = {'title': portlet.title, 'link': portlet.link}
+        info.metadata = {'title': self.title, 'link': self.link}
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml      
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml      
Tue Oct 25 00:42:15 2005
@@ -16,10 +16,6 @@
       icon="image-icon.png"
   />
 
-  <zope:adapter
-      factory=".ImagePortletData"
-  />
-
   <!-- The portlet's presentation -->
 
   <presentation

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     
Tue Oct 25 00:42:15 2005
@@ -27,7 +27,7 @@
 
 from cpsskins import getContexts
 from cpsskins.elements.portlet import Portlet
-from cpsskins.interfaces import IPortlet, IContextInfo, IDisplayData
+from cpsskins.interfaces import IPortlet
 
 _ = MessageFactory("cpsskins")
 
@@ -48,19 +48,7 @@
     def __init__(self, title=''):
         self.title = title
 
-class MacroSlotPortletData(object):
-    """The macro slot's portlet's display data
-    """
-    adapts(IMacroSlotPortlet, IContextInfo)
-    implements(IDisplayData)
-
-    def __init__(self, portlet, info):
-        self.portlet = portlet
-        self.info = info
-
-    def __call__(self, **kw):
-        info = self.info
-        portlet = self.portlet
+    def __call__(self, info, **kw):
 
         request = info.request
         contexts = getContexts(request)
@@ -75,7 +63,7 @@
             markup = template(instance=view)
         else:
             macro_slot_editor = zapi.queryMultiAdapter(
-                (portlet, request), name='macroSlotEditor')
+                (self, request), name='macroSlotEditor')
             markup = macro_slot_editor()
 
         return markup

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml  
Tue Oct 25 00:42:15 2005
@@ -17,10 +17,6 @@
       icon="macroslot-icon.png"
   />
 
-  <zope:adapter
-      factory=".MacroSlotPortletData"
-  />
-
   <!-- The portlet's presentation -->
 
   <presentation
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to