Author: jmorliaguet
Date: Sat Oct 29 01:55:37 2005
New Revision: 28794

Modified:
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/portlet_edit.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/slot_edit.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/layout.py
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/portlet_edit.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/slot_edit.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/theme_edit_layout.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/themepage_edit_layout.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py
   z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/effect/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/htmlcleaner/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/layout/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.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/custom/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py
Log:

- simplifications:

  - Filters adapt IDsplay to IFilter (removed unused request)

  - the info structure is local for each renderer but it contains a 
    copy of a global context info structure. All global variables
    can be accessed with:

    info.globals or info/globals (in ZPT) or info['globals']

    for instance:

    request = info.globals.request
    view = info.globals.view
    engine = info.globals.engine

    **kw variables are current set in globals too (the ones that are
    not mandatory may be moved to 'info.controls' for instance)

  - keyword arguments are no longer passed to filters (the info
    structure is not used instead)




Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt
      (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt
      Sat Oct 29 01:55:37 2005
@@ -1,11 +1,11 @@
 <td class="editable" style="vertical-align:top"
   tal:define="
     info options/info;
-    perspective info/perspective;
-    rendered options/rendered;
+    globals nocall:info/globals;
     display info/display;
+    perspective globals/perspective;
     formats display/formattable:getFormatNames;
-    canvas_mode options/canvas_mode|nothing;
+    canvas_mode globals/canvas_mode|nothing;
     mode_is_layout python:canvas_mode == 'layout';
     title context/title;
     id view/getId;
@@ -39,6 +39,6 @@
   </form>
 
   <div class="container" focus="1"
-       tal:content="structure rendered" />
+       tal:content="structure options/markup" />
 
 </td>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/__init__.py
      (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/__init__.py
      Sat Oct 29 01:55:37 2005
@@ -17,27 +17,26 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.app.publisher.browser import BrowserView
 from zope.component import adapts, getMultiAdapter
 from zope.interface import implements
-from zope.publisher.interfaces import IRequest
 
 from cpsskins.browser.rendering.interfaces import IFilter
 from cpsskins.elements.interfaces import IDisplay
 
-class EditorFilter(BrowserView):
+class EditorFilter(object):
     """A display filter view that applies an editor to an element.
 
     The element must provide a page named 'editor (content authoring)'
     """
-    adapts(IDisplay, IRequest)
+    adapts(IDisplay)
     implements(IFilter)
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __init__(self, context):
+        self.context = context
+
+    def __call__(self, markup, info):
         """Apply the editor.
         """
-        request = self.request
-
-        editor = getMultiAdapter((info.element, request),
+        editor = getMultiAdapter((info.element, info.globals.request),
             name='editor (content authoring)')
-        return editor(rendered=rendered, info=info, **kw)
+        return editor(markup=markup, info=info)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/portlet_edit.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/portlet_edit.pt
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/portlet_edit.pt
  Sat Oct 29 01:55:37 2005
@@ -18,6 +18,6 @@
     class python: editable and 'editable draggable hover' or nothing;
     id id">
 
-  <div tal:content="structure options/rendered" />
+  <div tal:content="structure options/markup" />
 
 </div>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/slot_edit.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/slot_edit.pt
     (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/slot_edit.pt
     Sat Oct 29 01:55:37 2005
@@ -1,5 +1,5 @@
 <tal:block define="
-  rendered options/rendered;
+  markup options/markup;
   slot_title context/title;
   slot_name context;
   id view/getId;
@@ -8,8 +8,8 @@
   <div class="slotFrame container" render="1"
        tal:attributes="id id">
     <div class="title" tal:content="slot_title|slot_name" />
-    <div class="body" tal:condition="rendered"
-         tal:content="structure rendered" />
+    <div class="body" tal:condition="markup"
+         tal:content="structure markup" />
   </div>
 
 </tal:block>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/layout.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/layout.py    
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/layout.py    
    Sat Oct 29 01:55:37 2005
@@ -19,7 +19,6 @@
 
 from zope.component import adapts, getMultiAdapter
 from zope.interface import implements
-from zope.publisher.interfaces import IRequest
 
 from cpsskins.elements.formats.interfaces import IFormat
 from cpsskins.browser.rendering.interfaces import IFilter
@@ -27,20 +26,20 @@
 class LayoutEditor(object):
     """Apply a layout editor to the elements.
     """
-    adapts(IFormat, IRequest)
+    adapts(IFormat)
     implements(IFilter)
 
-    def __init__(self, context, request):
+    def __init__(self, context):
         self.context = context
-        self.request = request
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __call__(self, markup, info):
         """Apply the layout editor.
         """
         layout = self.context
-        request = self.request
-
         element = info.element
+        request = info.globals.request
 
         editor = getMultiAdapter((element, request), name='editor (layout)')
-        return editor(rendered=rendered, layout=layout, info=info, **kw)
+       print element
+       print editor
+        return editor(markup=markup, layout=layout, info=info)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/__init__.py
 (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/__init__.py
 Sat Oct 29 01:55:37 2005
@@ -17,27 +17,26 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.app.publisher.browser import BrowserView
 from zope.component import adapts, getMultiAdapter
 from zope.interface import implements
-from zope.publisher.interfaces import IRequest
 
 from cpsskins.browser.rendering.interfaces import IFilter
 from cpsskins.elements.interfaces import IDisplay
 
-class EditorFilter(BrowserView):
+class EditorFilter(object):
     """A display filter view that applies an editor to an element.
 
     The element must provide a page named 'editor (page authoring)'
     """
-    adapts(IDisplay, IRequest)
+    adapts(IDisplay)
     implements(IFilter)
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __init__(self, context):
+        self.context = context
+
+    def __call__(self, markup, info):
         """Apply the editor to the element.
         """
-        request = self.request
-
-        editor = getMultiAdapter((info.element, request),
+        editor = getMultiAdapter((info.element, info.globals.request),
             name='editor (page authoring)')
-        return editor(rendered=rendered, info=info, **kw)
+        return editor(markup=markup, info=info)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/portlet_edit.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/portlet_edit.pt
     (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/portlet_edit.pt
     Sat Oct 29 01:55:37 2005
@@ -1,9 +1,10 @@
 <div class="editable draggable hover"
   tal:define="
     info options/info;
+    globals info/globals;
     display info/display;
-    perspective info/perspective;
-    canvas_mode options/canvas_mode|nothing;
+    perspective globals/perspective;
+    canvas_mode globals/canvas_mode|nothing;
     mode_is_layout python:canvas_mode == 'layout';
     formats display/formattable:getFormatNames;
     title context/title;
@@ -22,6 +23,6 @@
 
     <div
       tal:condition="not:mode_is_layout"
-      tal:content="structure options/rendered" />
+      tal:content="structure options/markup" />
 
 </div>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/slot_edit.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/slot_edit.pt
        (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/slot_edit.pt
        Sat Oct 29 01:55:37 2005
@@ -1,6 +1,5 @@
 <tal:block define="
   info options/info;
-  rendered options/rendered;
   perspective info/perspective;
   display info/display;
   formats display/formattable:getFormatNames;

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt
 (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt
 Sat Oct 29 01:55:37 2005
@@ -1,9 +1,10 @@
 <tal:block
   define="
-    canvas_mode options/canvas_mode|nothing;
     info options/info;
-    perspective info/perspective;
+    globals info/globals;
     display info/display;
+    canvas_mode globals/canvas_mode|nothing;
+    perspective globals/perspective;
     formats display/formattable:getFormatNames;
     mode_is_layout python:canvas_mode == 'layout';
     title context/title;
@@ -14,7 +15,7 @@
 
   <table tal:condition="not:mode_is_layout" cellpadding="0" cellspacing="0"
    tal:attributes="width width">
-    <tr tal:content="structure options/rendered" />
+    <tr tal:content="structure options/markup" />
   </table>
 
   <table tal:condition="mode_is_layout" cellpadding="0" cellspacing="0"
@@ -51,7 +52,7 @@
           tal:attributes="editable python:1;
                           folder_editable python:1;
                           id this_id">
-          <tr tal:content="structure options/rendered" />
+          <tr tal:content="structure options/markup" />
         </table>
       </td>
     </tr>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/theme_edit_layout.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/theme_edit_layout.pt
     (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/theme_edit_layout.pt
     Sat Oct 29 01:55:37 2005
@@ -1 +1 @@
-<tal:block content="structure options/rendered" />
+<tal:block content="structure options/markup" />

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/themepage_edit_layout.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/themepage_edit_layout.pt
 (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/themepage_edit_layout.pt
 Sat Oct 29 01:55:37 2005
@@ -1,3 +1,3 @@
 <div tal:define="id view/getId"
      tal:attributes="id id"
-     tal:content="structure options/rendered" />
+     tal:content="structure options/markup" />

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 29 01:55:37 2005
@@ -60,10 +60,8 @@
     >>> c.display
     'some display'
 
-    >>> c.style
-    Traceback (most recent call last):
-    ...
-    AttributeError: No such variable 'style' in this context
+    >>> c.style is None
+    True
 
     >>> c.style = 'some style'
     >>> c.style
@@ -79,6 +77,12 @@
     >>> c.items()
     [('display', 'some other display'), ('element', 'some element')]
 
+    >>> a = ContextInfo()
+    >>> b = ContextInfo({'c': 'some value'})
+    >>> a.b = b
+    >>> a.b.c
+    'some value'
+
     """
     implements(IContextInfo)
 
@@ -87,6 +91,9 @@
         self.contexts = {}
         self.update(contexts)
 
+    def __call__(self):
+        return self
+
     def __getitem__(self, name):
         return getattr(self, name)
 
@@ -96,9 +103,7 @@
     def __getattr__(self, name):
         if name in self.contexts:
             return self.contexts[name]
-        else:
-            raise AttributeError(
-                "No such variable '%s' in this context" % name)
+        return None
 
     def items(self):
         return self.contexts.items()
@@ -130,6 +135,9 @@
         self.element = element
         self.request = request
 
+    def __call__(self, **kw):
+        element = self.element
+        request = self.request
         contexts = getContexts(request)
 
         theme = getThemeManager().getThemeInContext(element)
@@ -137,28 +145,23 @@
         perspective = getMultiAdapter((element, request),
                                        INegociation).getPerspective()
 
-        contexts['theme'] = theme
         contexts['relations'] = relations
+        contexts['theme']  = theme
 
-        # build the tree and store it in the request
-        contexts['tree'] = _buildTreeInfo(node=element, request=request,
-                                          perspective=perspective)
-
-    def __call__(self, **kw):
-        element = self.element
-        request = self.request
+        # update global context info variables passed as keyword parameters
+        globals = ContextInfo(kw)
+        globals.update({
+            'perspective': perspective,
+            'request': request,
+            })
 
-        # update global context info variables pass as keyword parameters
-        contexts = getContexts(request)
-        contexts['view'] = kw.get('view')
-        contexts['location'] = kw.get('location')
-        contexts['template'] = kw.get('template')
-        contexts['engine'] = kw.get('engine', 'default')
+        # build the tree and store it in the request
+        contexts['tree'] = _updateTreeInfo(node=element, globals=globals)
 
         # render the tree
-        return getMultiAdapter((element, request), IRenderer)(**kw)
+        return getMultiAdapter((element, request), IRenderer)()
 
-def _buildTreeInfo(index={}, node=None, request=None, perspective=None):
+def _updateTreeInfo(index={}, node=None, globals=None):
     """Build the tree info for an element.
     """
 
@@ -169,34 +172,38 @@
     node_index = index[node.identifier] = {}
 
     # if the object is inside a slot, get the parent's display.
+    # TODO this should be moved somewhere else
+
+
+    perspective = globals.perspective
     display = IDisplayable(node).getEffectiveDisplay(perspective)
     if display is None:
         parent = getParent(node)
         if ISlot.providedBy(parent):
             display = IDisplayable(parent).getEffectiveDisplay(perspective)
 
-    children = INodeTraverser(node).getChildNodes(display=display,
-                                                  perspective=perspective)
+    traverser = INodeTraverser(node)
+    children = traverser.getChildNodes(display=display, 
perspective=perspective)
 
-    info = ContextInfo(
-        {'element': node,
-         'display': display,
-         'request': request,
-         'perspective': perspective,
-         'data': None,
-         'metadata': None,
-         })
+    info = ContextInfo({
+        'element': node,
+        'display': display,
+        'data': None,
+        'metadata': None,
+        })
+
+    # set global variables
+    info.globals = globals
 
-    node_index['children'] = children
     node_index['info'] = info
+    node_index['children'] = children
 
     update = IUpdateData(node, None) 
     if update is not None:
         update(info)
 
     for child in children:
-        _buildTreeInfo(index=index, node=child, request=request,
-                       perspective=perspective)
+        _updateTreeInfo(index=index, node=child, globals=globals)
 
     return index
 
@@ -211,18 +218,18 @@
         self.element = element
         self.request = request
 
-    def __call__(self, **kw):
+    def __call__(self):
         """Do the actual rendering by applying all filters.
         """
         element = self.element
         request = self.request
 
         contexts = getContexts(request)
-        element_info = contexts['tree'][element.identifier]
-        engine = contexts['engine']
+        tree_element = contexts['tree'][element.identifier]
 
         # set local context info variables
-        info = element_info['info']
+        info = tree_element['info']
+        engine = info.globals.engine
 
         rendered = []
         if ILeaf.providedBy(element):
@@ -230,14 +237,14 @@
             portlet_markup = element(info) or ''
             rendered.append(portlet_markup)
         else:
-            for node in element_info['children']:
+            for node in tree_element['children']:
                 if not INode.providedBy(node):
                     logger.log(INFO,
                         "The object '%s' is not a valid node." % repr(node))
                     continue
                 renderer = getMultiAdapter((node, request), IRenderer)
-                rendered.append(renderer(**kw))
-        rendered = ''.join(rendered)
+                rendered.append(renderer())
+        markup = ''.join(rendered)
 
         # look for renderers associated to the element's content type
         iface = IType(element).getContentType()
@@ -249,15 +256,15 @@
             logger.log(INFO,
                 "The element '%s' cannot be rendered by the '%s' engine."
                 % (repr(element), engine))
-            return rendered
+            return markup
 
         display = info['display']
         # apply all filters
         for f in self._getFilters(iface, display, engine):
-            rendered = f(rendered, info, **kw)
+            markup = f(markup, info)
 
         # Filter output
-        return rendered
+        return markup
 
     def _getFilters(self, iface, display, engine):
         """Get the list of filters
@@ -293,7 +300,7 @@
 
                 # get the adapter
                 filter = queryMultiAdapter(
-                    objects=(adapted, request),
+                    objects=(adapted,),
                     interface=IFilter,
                     name=filter_name,
                     default=None)
@@ -307,7 +314,7 @@
 
             # the filter id refers to an adapter
             elif IFilter.implementedBy(filter_id):
-                filter = filter_id(display, request)
+                filter = filter_id(display)
 
             else:
                 raise ConfigurationError(

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/filters/metaconfigure.py 
    Sat Oct 29 01:55:37 2005
@@ -22,7 +22,6 @@
 from zope.app.publisher.browser.resourcemeta import resource
 from zope.component import provideAdapter, getUtility
 from zope.configuration.exceptions import ConfigurationError
-from zope.publisher.interfaces.browser import IBrowserRequest
 
 from cpsskins.configuration.interfaces import IRegistry
 
@@ -57,7 +56,7 @@
     _context.action(
         discriminator = ('adapter', factory, for_, name),
         callable = provideAdapter,
-        args = (factory, (for_, IBrowserRequest), IFilter, name),
+        args = (factory, (for_,), IFilter, name),
         )
 
     # register resources

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 
29 01:55:37 2005
@@ -30,7 +30,8 @@
    to obtain the data, the portlet's __call__() method is called:
 
     >>> from cpsskins.browser.rendering.engine import ContextInfo
-    >>> info = ContextInfo({'request': request, 'data': None, 'metadata': 
None})
+    >>> info = ContextInfo({'data': None, 'metadata': None})
+    >>> info.globals = ContextInfo({'request': request})
 
     >>> portlet(info=info)
     u'Dummy text.'
@@ -86,10 +87,10 @@
     >>> from cpsskins.browser.rendering.interfaces import IFilter
     >>> from cpsskins.elements.formats.interfaces import IWidget
 
-    >>> ztapi.provideAdapter((IWidget, IRequest), IFilter, WidgetFilter)
+    >>> ztapi.provideAdapter((IWidget,), IFilter, WidgetFilter)
 
     >>> def test_render(widget, rendered, info):
-    ...    widget_filter = getMultiAdapter((widget, request), IFilter)
+    ...    widget_filter = IFilter(widget)
     ...    return widget_filter(rendered, info)
 
     >>> test_render(widget, rendered, info)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/effect/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/effect/__init__.py
 (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/effect/__init__.py
 Sat Oct 29 01:55:37 2005
@@ -44,14 +44,13 @@
 class EffectFilter(object):
     """Applies effects on objects.
     """
-    adapts(IDisplay, IRequest)
+    adapts(IDisplay)
     implements(IFilter)
 
-    def __init__(self, context, request):
+    def __init__(self, context):
         self.context = context
-        self.request = request
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __call__(self, markup, info):
         """Apply the filter.
         """
         data = info.data

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/htmlcleaner/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/htmlcleaner/__init__.py
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/htmlcleaner/__init__.py
    Sat Oct 29 01:55:37 2005
@@ -21,7 +21,6 @@
 
 from zope.component import adapts
 from zope.interface import implements
-from zope.publisher.interfaces import IRequest
 
 from cpsskins.elements.displays.interfaces import IDisplay
 from cpsskins.browser.rendering.interfaces import IFilter
@@ -29,19 +28,16 @@
 class HTMLCleaner(object):
     """Cleans and optimizes the html code.
 
-    >>> from zope.publisher.browser import TestRequest
-    >>> request = TestRequest()
-
     >>> o = object()
-    >>> c = HTMLCleaner(o, request)
+    >>> c = HTMLCleaner(o)
 
-    >>> c(rendered='<div> Some text </div>')
+    >>> c(markup='<div> Some text </div>', info=None)
     '<div> Some text </div>'
 
-    >>> c(rendered='<div> Some text </div>     <p>Some other text</p>')
+    >>> c(markup='<div> Some text </div>     <p>Some other text</p>', 
info=None)
     '<div> Some text </div> <p>Some other text</p>'
 
-    >>> c(rendered=\"""
+    >>> c(markup=\"""
     ...
     ...         <div>Some text
     ...
@@ -50,25 +46,24 @@
     ...         </div>
     ...
     ...
-    ...        \""")
+    ...        \""", info=None)
     '<div>Some text\\n\\n          <p>Some other text</p> </div>'
 
     """
 
-    adapts(IDisplay, IRequest)
+    adapts(IDisplay)
     implements(IFilter)
 
-    def __init__(self, context, request):
+    def __init__(self, context):
         self.context = context
-        self.request = request
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __call__(self, markup, info):
         """Apply the filter"""
 
         # remove spaces
-        rendered = re.sub(r'>\s+<','> <', rendered)
-        rendered = re.sub(r'\n\s+\n','', rendered)
-        rendered = re.sub(r'^\s+<','<', rendered)
-        rendered = re.sub(r'>\s+$','>', rendered)
+        markup = re.sub(r'>\s+<','> <', markup)
+        markup = re.sub(r'\n\s+\n','', markup)
+        markup = re.sub(r'^\s+<','<', markup)
+        markup = re.sub(r'>\s+$','>', markup)
 
-        return rendered
+        return markup

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/layout/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/layout/__init__.py
 (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/layout/__init__.py
 Sat Oct 29 01:55:37 2005
@@ -21,7 +21,6 @@
 
 from zope.component import adapts
 from zope.interface import implements
-from zope.publisher.interfaces import IRequest
 from zope.security.proxy import removeSecurityProxy
 
 from cpsskins.elements.formats.interfaces import IFormat
@@ -49,9 +48,6 @@
     - form
     - ul
 
-    >>> from zope.publisher.browser import TestRequest
-    >>> request = TestRequest()
-
     >>> from zope.app.container.btree import BTreeContainer
     >>> class FakeLayout(BTreeContainer):
     ...    def __init__(self, type='plain'):
@@ -64,54 +60,53 @@
     >>> l['padding'] = ''
     >>> l['width'] = ''
     >>> l['align'] = ''
-    >>> f = LayoutFilter(l, request)
-    >>> f('<div class="box">Box</div>')
+    >>> f = LayoutFilter(l)
+    >>> f('<div class="box">Box</div>', info=None)
     '<div class="box">Box</div>'
 
     >>> l = FakeLayout('plain')
     >>> l['padding'] = '1em'
     >>> l['width'] = '100%'
     >>> l['align'] = 'right'
-    >>> f = LayoutFilter(l, request)
+    >>> f = LayoutFilter(l)
 
-    >>> f('<p>Text</p>')
+    >>> f('<p>Text</p>', info=None)
     Traceback (most recent call last):
     ...
     ValueError: Layout filter: <p> is not allowed. \
 Only the following tags are supported: div, img, table, tr, td, fieldset, 
form, ul
 
-    >>> f('<div class="box">Box</div>')
+    >>> f('<div class="box">Box</div>', info=None)
     '<div class="box" 
style="text-align:right;padding:1em;width:100%;">Box</div>'
 
 
-    >>> f('<div style="vertical-align:top">Box</div>')
+    >>> f('<div style="vertical-align:top">Box</div>', info=None)
     '<div 
style="vertical-align:top;text-align:right;padding:1em;width:100%;">Box</div>'
 
     >>> l = FakeLayout('plain')
     >>> l['padding'] = '1em'
     >>> l['width'] = '100%'
-    >>> f = LayoutFilter(l, request)
-    >>> f('<div style="vertical-align:top;color:red">Box</div>')
+    >>> f = LayoutFilter(l)
+    >>> f('<div style="vertical-align:top;color:red">Box</div>', info=None)
     '<div 
style="vertical-align:top;color:red;padding:1em;width:100%;">Box</div>'
     """
 
-    adapts(IFormat, IRequest)
+    adapts(IFormat)
     implements(IFilter)
 
-    def __init__(self, context, request):
+    def __init__(self, context):
         self.context = context
-        self.request = request
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __call__(self, markup, info):
         """Apply the layout filter.
         """
         style_attr = self._getStyleAttr()
         if not style_attr:
-            return rendered
+            return markup
 
-        s = startTag.search(rendered)
+        s = startTag.search(markup)
         if s is None:
-            return rendered
+            return markup
         res = s.group()
         in_brackets = res[1:-1]
 
@@ -133,8 +128,7 @@
 
         style_attrs.append(style_attr)
         final = '<%s style="%s">' % (in_brackets, ';'.join(style_attrs))
-        rendered = startTag.sub(final, rendered, count=1)
-        return rendered
+        return startTag.sub(final, markup, count=1)
 
     def _getStyleAttr(self, tag=''):
         """Get the style attribute for a given tag.

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py
  Sat Oct 29 01:55:37 2005
@@ -21,7 +21,6 @@
 
 from zope.interface import implements
 from zope.component import adapts
-from zope.publisher.interfaces import IRequest
 
 from cpsskins.elements.formats.interfaces import IStyle, ICSSRenderer
 from cpsskins.browser.rendering.interfaces import IFilter
@@ -35,9 +34,7 @@
     some HTML markup. The CSS class name is obtained from the adapted object
     (e.g. a Style Format element)
 
-    >>> from zope.publisher.browser import TestRequest
     >>> from zope.interface import implements
-    >>> request = TestRequest()
 
     >>> class FakeStyle:
     ...    implements(IStyle)
@@ -53,45 +50,44 @@
     >>> s.identifier
     '12345'
 
-    >>> f = StyleFilter(s, request)
+    >>> f = StyleFilter(s)
 
-    >>> f(rendered='<div>Some content</div>')
+    >>> f(markup='<div>Some content</div>', info=None)
     '<div class="style12345">Some content</div>'
 
-    >>> f(rendered='<div\\n>Some content</div>')
+    >>> f(markup='<div\\n>Some content</div>', info=None)
     '<div class="style12345">Some content</div>'
 
-    >>> f(rendered='<div style="color:red">Some content</div>')
+    >>> f(markup='<div style="color:red">Some content</div>', info=None)
     '<div style="color:red" class="style12345">Some content</div>'
 
-    >>> f(rendered='<div style="color:red"><p>Some content</p></div>')
+    >>> f(markup='<div style="color:red"><p>Some content</p></div>', info=None)
     '<div style="color:red" class="style12345"><p>Some content</p></div>'
 
-    >>> f(rendered='<div style="color:red" class="box">A box</div>')
+    >>> f(markup='<div style="color:red" class="box">A box</div>', info=None)
     '<div style="color:red" class="box style12345">A box</div>'
 
-    >>> f(rendered='<p class="fancy blue" style="color:red">Text</p>')
+    >>> f(markup='<p class="fancy blue" style="color:red">Text</p>', info=None)
     '<p style="color:red" class="fancy blue style12345">Text</p>'
 
-    >>> f(rendered='<p style="color:red" class="fancy blue">Text</p>')
+    >>> f(markup='<p style="color:red" class="fancy blue">Text</p>', info=None)
     '<p style="color:red" class="fancy blue style12345">Text</p>'
 
     """
 
-    adapts(IStyle, IRequest)
+    adapts(IStyle)
     implements(IFilter)
 
-    def __init__(self, context, request):
+    def __init__(self, context):
         self.context = context
-        self.request = request
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __call__(self, markup, info):
         """Apply the style to the markup.
         """
-        rendered = lineBreaks.sub('', rendered)
-        s = startTag.search(rendered)
+        markup = lineBreaks.sub('', markup)
+        s = startTag.search(markup)
         if s is None:
-            return rendered
+            return markup
         res = s.group()
         in_brackets = res[1:-1]
         c = classAttr.search(in_brackets)
@@ -103,5 +99,5 @@
             class_attrs = []
         class_attrs.append(str(ICSSRenderer(self.context)))
         final = '<%s class="%s">' % (in_brackets, ' '.join(class_attrs))
-        return startTag.sub(final, rendered, count=1)
+        return startTag.sub(final, markup, count=1)
 

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/__init__.py
 (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/__init__.py
 Sat Oct 29 01:55:37 2005
@@ -44,18 +44,17 @@
 class WidgetFilter:
     """Presents data by means of widgets.
     """
-    adapts(IWidget, IRequest)
+    adapts(IWidget)
     implements(IFilter)
 
-    def __init__(self, context, request):
+    def __init__(self, context):
         self.context = context
-        self.request = request
 
-    def __call__(self, rendered='', info=None, **kw):
+    def __call__(self, markup, info):
         """Apply the widget filter.
         """
         context = self.context
-        request = self.request
+        request = info.globals.request
 
         widget_id = context.getWidgetId()
         if widget_id is None:
@@ -63,7 +62,7 @@
                 "'%s' cannot be displayed. Widget '%s' is unknown."
                 % (repr(info.element), widget_id)
                 )
-            return rendered
+            return markup
 
         data = info.data
 
@@ -84,9 +83,9 @@
                                         interface=IBasicWidgetView)
 
             if factory is None:
-                return rendered
+                return markup
 
-        return factory(rendered=rendered, info=info, **kw)
+        return factory(markup=markup, info=info)
 
 class WidgetView(BrowserView):
     """Widgets are used for formatting elements using some HTML markup.

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.py
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.py
  Sat Oct 29 01:55:37 2005
@@ -26,10 +26,10 @@
     """
     _markup = '' # the content will be inserted in %(content)s 
 
-    def __call__(self, rendered, info, **kw):
-        rendered = self._markup % {'content': rendered}
+    def __call__(self, markup, info, **kw):
+        markup = self._markup % {'content': markup}
         # TODO: rendering optional link
-        return rendered
+        return markup
 
 class MenuView(WidgetView):
     """A menu view display a list of clickable items.
@@ -39,27 +39,27 @@
     _separator = '' # Optional
     _end = ''       # Optional
 
-    def __call__(self, rendered, info, **kw):
+    def __call__(self, markup, info, **kw):
         start = self._start
         repeat = self._repeat
         separator = self._separator
         end = self._end
 
-        rendered = []
-        rendered_append = rendered.append
+        markup = []
+        markup_append = markup.append
         if start:
-            rendered_append(start)
+            markup_append(start)
         for item in info.data:
-            rendered_append(repeat % {
+            markup_append(repeat % {
                 'url': item['url'],
                 'title': item['title'],
                 })
             if separator:
-                rendered_append(separator)
+                markup_append(separator)
         if end:
-            rendered_append(end)
+            markup_append(end)
         # TODO: rendering optional link
-        return ''.join(rendered)
+        return ''.join(markup)
 
 
 # The actual widget views
@@ -78,26 +78,26 @@
                '<p label="paragraph">Some paragraph</p>' \
                '</div>'
 
-    def __call__(self, rendered, info, **kw):
-        return '<div>%s</div>' % rendered
+    def __call__(self, markup, info, **kw):
+        return '<div>%s</div>' % markup
 
 class BasicImageView(WidgetView):
     """Display an image with minimal formatting
     """
-    def __call__(self, rendered, info, **kw):
+    def __call__(self, markup, info, **kw):
         return Image(self.context, self.request)(info.data)
 
 class BasicItemView(WidgetView):
     """Display an item with minimal formatting
     """
-    def __call__(self, rendered, info, **kw):
+    def __call__(self, markup, info, **kw):
         data = info.data
         return '<a href="%s">%s</a>' % (data.url, data.title)
 
 class BasicItemsView(WidgetView):
     """Display a series of items with minimal formatting
     """
-    def __call__(self, rendered, info, **kw):
+    def __call__(self, markup, info, **kw):
         data = info.data
         markup = []
         items_append = markup.append
@@ -113,7 +113,7 @@
     """
     _preview = '<img src="#" alt="" style="border: none" />'
 
-    def __call__(self, rendered, info, **kw):
+    def __call__(self, markup, info, **kw):
         data = info.data
         markup = ''
         url = data.path or data.url
@@ -202,12 +202,12 @@
                '<a label="link" href="#">some link</a>' \
                '</fieldset>'
 
-    def __call__(self, rendered, info, **kw):
+    def __call__(self, markup, info, **kw):
         data = info.data
         metadata = info.metadata
         title = metadata and metadata.title or ''
         return '<fieldset><legend>%s</legend>%s</fieldset>' % (
-                title, BasicHTMLView(self.context, self.request)(rendered, 
info))
+                title, BasicHTMLView(self.context, self.request)(markup, info))
 
 
 class HorizontalScrollBar(HTMLView):

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 29 01:55:37 2005
@@ -25,7 +25,6 @@
 from zope.schema import TextLine
 from zope.i18nmessageid import MessageFactory
 
-from cpsskins import getContexts
 from cpsskins.interfaces import IPortlet
 from cpsskins.model import Items, Item
 
@@ -49,11 +48,11 @@
 
     def __call__(self, info):
 
-        request = info.request
-        contexts = getContexts(request)
+        request = info.globals.request
+        location = info.globals.location
 
         try:
-           menu = getMenu(self.category, contexts['location'], request)
+           menu = getMenu(self.category, location, request)
         except ComponentLookupError:
            items = []
         else:

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 29 01:55:37 2005
@@ -41,10 +41,10 @@
         self.title = title
 
     def __call__(self, info):
-        request = info.request
-        contexts = request.annotations['cpsskins.contexts']
+        request = info.globals.request
+        location = info.globals.location
 
-        url = getMultiAdapter((contexts['location'], request), IAbsoluteURL)
+        url = getMultiAdapter((location, request), IAbsoluteURL)
         items = [
             Item(title=bc['name'], url=bc['url'])
             for bc in url.breadcrumbs()

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 29 01:55:37 2005
@@ -29,7 +29,6 @@
 from zope.schema import Choice, Text
 from zope.schema.vocabulary import SimpleVocabulary
 
-from cpsskins import getContexts
 from cpsskins.interfaces import IPortlet
 
 _ = MessageFactory("cpsskins")
@@ -71,12 +70,11 @@
 
     def __call__(self, info):
         request = info.request
-        contexts = getContexts(request)
 
         format = self.format
         if format in page_factories:
             page = page_factories[format]()
-            page = contained(page, contexts['location'])
+            page = contained(page, info.globals.location)
             page.setSource(self.source)
             markup = unicode(_renderPage(page, request))
         else:

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 29 01:55:37 2005
@@ -26,7 +26,6 @@
 from zope.publisher.interfaces.browser import ILayer, IDefaultBrowserLayer
 from zope.publisher.interfaces.browser import IBrowserRequest
 
-from cpsskins import getContexts
 from cpsskins.interfaces import IPortlet
 
 _ = MessageFactory("cpsskins")
@@ -51,12 +50,11 @@
     def __call__(self, info):
 
         request = info.request
-        contexts = getContexts(request)
 
-        view = contexts['view']
-        template = contexts['template']
+        view = info.globals.view
+        template = info.globals.template
 
-        if view is not None:
+        if view is not None and template is not None:
             # Switch to the macroless skin before rendering the view
             applySkin(request, IMacrolessSkin)
             # Render the view
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to