Author: jmorliaguet
Date: Sat Nov  5 15:25:24 2005
New Revision: 29015

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py
   z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/configure.zcml
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.zcml
   
z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py
   z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py
Log:

- removed widget types until they are correctly implemented



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 Nov  5 15:25:24 2005
@@ -293,7 +293,8 @@
         for filter_name in renderer.filters:
             filter_proxy = queryUtility(IFilter, filter_name)
             if filter_proxy is None:
-                logger.log(INFO, "Filter '%s' is not registered." % 
filter_proxy)
+                logger.log(INFO,
+                    "Filter '%s' is not registered." % filter_proxy)
                 continue
 
             factory = filter_proxy.factory
@@ -306,8 +307,7 @@
                     logger.log(INFO,
                         "Filter '%s' will not be applied. "
                         "Filter predicates of arity %s are not supported."
-                        % (filter_proxy, len(predicate))
-                        )
+                        % (filter_proxy, len(predicate)))
                     continue
                 res = relations.search(predicate=predicate, first=display)
                 if not res:
@@ -357,5 +357,4 @@
         self.template = template
 
     def __call__(self, markup, info):
-        kw = {'markup': markup, 'info': info}
-        return self.template(self, **kw)
+        return self.template(self, **{'markup': markup, 'info': info})

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/__init__.py  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/__init__.py  
Sat Nov  5 15:25:24 2005
@@ -17,11 +17,3 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.component import provideUtility
-
-from cpsskins.configuration import ConfigurationRegistry
-from cpsskins.configuration.interfaces import IRegistry
-
-provideUtility(ConfigurationRegistry(), IRegistry, 'widgets')
-provideUtility(ConfigurationRegistry(), IRegistry, 'widget types')
-

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py 
    Sat Nov  5 15:25:24 2005
@@ -18,7 +18,7 @@
 __docformat__ = "reStructuredText"
 
 from zope.app.component.metaconfigure import adapter
-from zope.component import getUtility, provideUtility
+from zope.component import queryUtility, provideUtility
 from zope.configuration.exceptions import ConfigurationError
 from zope.i18nmessageid import MessageFactory
 from zope.publisher.interfaces.browser import IBrowserRequest
@@ -30,17 +30,13 @@
 
 _ = MessageFactory("cpsskins")
 
-widget_type_registry = getUtility(IRegistry, 'widget types')
 registered_adapters = []
 
-def widget(_context=None, id=None, type=None, title=None, factory=None):
+def widget(_context=None, id=None, title=None, factory=None):
 
     if not id:
         raise ConfigurationError("Must specify the widget id.")
 
-    if not type:
-        raise ConfigurationError("Must specify the widget type.")
-
     if not title:
         raise ConfigurationError("Must specify a widget title.")
 
@@ -48,14 +44,9 @@
         raise ConfigurationError("Must specify a widget factory.")
 
     # register widgets
-    provideUtility(Widget(title=title, type=type, factory=factory), IWidget, 
id)
+    provideUtility(Widget(id=id, title=title, factory=factory), IWidget, id)
 
     # zope:adapter
     adapter(_context=_context, factory=(factory,), provides=IWidgetView,
         for_=(IWidget, IBrowserRequest), name=id)
 
-    # register the widget type
-    types = widget_type_registry.get(type, [])
-    types.append(id)
-    widget_type_registry.update(type, types)
-

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py
    Sat Nov  5 15:25:24 2005
@@ -33,13 +33,6 @@
         default=u'',
        )
 
-    type = GlobalObject(
-        title=_("Type"),
-        description=_("The widget's type"),
-        required=False,
-        default=u'',
-       )
-
     title = TextLine(
         title=_("Title"),
         description=_("The widget's title"),

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 Nov 
 5 15:25:24 2005
@@ -363,8 +363,3 @@
 class IDisplayType(IInterface):
     """The display type categorizes displays elements."""
 
-class IWidgetType(IInterface):
-    """The widget type categorizes widget elements."""
-
-class ILayoutType(IInterface):
-    """The layout type categorizes layout elements."""

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt
      (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/style/style_editor.pt
      Sat Nov  5 15:25:24 2005
@@ -23,7 +23,7 @@
    tal:define="displays context/findDisplays;
                display python: displays[0];
                widget display/formattable:widget;
-               widget_id widget/getWidgetId">
+               widget_id widget/id">
 
     <div class="editArea">
       <h1>Style editor</h1>
@@ -38,7 +38,7 @@
         <select id="widgetSelector">
           <tal:block repeat="display displays">
             <option tal:define="widget display/formattable:widget"
-                    tal:content="widget/getWidgetId" />
+                    tal:content="widget/id" />
           </tal:block>
         </select>
       </p>

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 Nov  5 15:25:24 2005
@@ -18,14 +18,13 @@
 __docformat__ = "reStructuredText"
 
 from zope.app.publisher.browser import BrowserView
-from zope.component import adapts, getUtility
+from zope.component import adapts, getUtility, getUtilitiesFor
 from zope.component import queryMultiAdapter, getMultiAdapter
 from zope.interface import implements
 from zope.i18nmessageid import MessageFactory
 from zope.schema.vocabulary import SimpleVocabulary
 
 from cpsskins.browser.rendering.interfaces import IFilterView
-from cpsskins.configuration.interfaces import IRegistry
 from cpsskins.engines.default.formats.interfaces import IWidget
 from interfaces import IBasicWidgetView, IWidgetView
 
@@ -37,8 +36,6 @@
 
 _ = MessageFactory("cpsskins")
 
-widget_type_registry = getUtility(IRegistry, 'widget types')
-
 class WidgetFilter:
     """Presents data by means of widgets.
     """
@@ -54,7 +51,7 @@
         context = self.context
         request = info.globals.request
 
-        widget_id = context.getWidgetId()
+        widget_id = context.id
         if widget_id is None:
             logger.log(INFO,
                 "'%s' cannot be displayed. Widget '%s' is unknown."
@@ -75,8 +72,7 @@
                 "'%s' with data '%s' could not be displayed "
                 "with the specified widget ('%s'). "
                 "Falling back to the basic widget view."
-                % (repr(info.element), repr(data), widget_id)
-                )
+                % (repr(info.element), repr(data), widget_id))
             factory = queryMultiAdapter(objects=(data, request),
                                         interface=IBasicWidgetView)
 
@@ -116,14 +112,3 @@
                 "the '_preview' attribute is missing in %s." % self.__class__
         return self._preview
 
-
-def WidgetsByTypeVocabulary(context):
-    """A vocabulary that contains the list of widgets in a given category.
-    """
-    widget_type = context.getWidgetType()
-    widgets = []
-    if widget_type is not None: 
-        for id in widget_type_registry[widget_type]:
-            widget = getUtility(IWidget, id)
-            widgets.append((_(widget.title), id))
-    return SimpleVocabulary.fromItems(widgets)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/configure.zcml
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/configure.zcml
      (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/configure.zcml
      Sat Nov  5 15:25:24 2005
@@ -21,11 +21,6 @@
       attribute="redirect"
   />
 
-  <vocabulary
-     name="WidgetsByType"
-     factory=".WidgetsByTypeVocabulary"
-  />
-
   <include file="widgets.zcml" />
 
 </configure>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.zcml
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.zcml
        (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/filters/widget/widgets.zcml
        Sat Nov  5 15:25:24 2005
@@ -6,28 +6,24 @@
 
   <widget
       id="plain_html"
-      type=".interfaces.IBasicWidgetView"
       factory=".widgets.BasicHTMLView"
       title="Basic HTML view"
   />
 
   <widget
       id="plain_image"
-      type=".interfaces.IBasicWidgetView"
       factory=".widgets.BasicImageView"
       title="Basic image view"
   />
 
   <widget
       id="plain_item"
-      type=".interfaces.IBasicWidgetView"
       factory=".widgets.BasicItemView"
       title="Basic item view"
   />
 
   <widget
       id="plain_items"
-      type=".interfaces.IBasicWidgetView"
       factory=".widgets.BasicItemsView"
       title="Basic items view"
   />
@@ -37,7 +33,6 @@
 
   <widget
       id="page_body"
-      type=".interfaces.IPageView"
       title="Page body"
       factory=".widgets.PageBody"
   />
@@ -47,14 +42,12 @@
 
   <widget
       id="table_frame"
-      type=".interfaces.IFrameView"
       title="Table frame"
       factory=".widgets.TableFrame"
   />
 
   <widget
       id="div_frame"
-      type=".interfaces.IFrameView"
       title="Div frame"
       factory=".widgets.DivFrame"
   />
@@ -64,21 +57,18 @@
 
   <widget
       id="table_cell"
-      type=".interfaces.ICellView"
       title="Table cell"
       factory=".widgets.TableCell"
   />
 
   <widget
       id="div_cell"
-      type=".interfaces.ICellView"
       title="Div cell"
       factory=".widgets.DivCell"
   />
 
   <widget
       id="horizontal_scrollbar"
-      type=".interfaces.ICellView"
       title="Horizontal scroll bar"
       factory=".widgets.HorizontalScrollBar"
   />
@@ -88,35 +78,30 @@
 
   <widget
       id="vertical_menu"
-      type=".interfaces.IMenuView"
       title="Vertical menu"
       factory=".widgets.VerticalMenu"
   />
 
   <widget
       id="horizontal_tabs"
-      type=".interfaces.IMenuView"
       title="Horizontal tabs"
       factory=".widgets.HorizontalTabs"
   />
 
   <widget
       id="menu_bar"
-      type=".interfaces.IMenuView"
       title="Menu bar"
       factory=".widgets.MenuBar"
   />
 
   <widget
       id="horizontal_trail"
-      type=".interfaces.IMenuView"
       title="Horizontal trail"
       factory=".widgets.HorizontalTrail"
   />
 
   <widget
       id="dropdown_list"
-      type=".interfaces.IMenuView"
       title="Drop-down list"
       factory=".widgets.DropDownList"
   />
@@ -126,7 +111,6 @@
 
   <widget
       id="frame_box"
-      type=".interfaces.IPlainView"
       title="Frame box"
       factory=".widgets.FrameBox"
   />
@@ -136,7 +120,6 @@
 
   <widget
       id="monthly_calendar"
-      type=".interfaces.ICalendarView"
       title="Monthly calendar"
       factory=".widgets.MonthlyCalendar"
   />
@@ -146,7 +129,6 @@
 
   <widget
       id="image"
-      type=".interfaces.IImageView"
       title="Image"
       factory=".widgets.Image"
   />

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/configure.zcml
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/configure.zcml 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/configure.zcml 
    Sat Nov  5 15:25:24 2005
@@ -1,4 +1,5 @@
 <configure
+    xmlns="http://namespaces.zope.org/zope";
     xmlns:cpsskins="http://namespaces.zope.org/cpsskins";>
 
   <!-- Layout -->
@@ -31,6 +32,10 @@
       template="../filters/widget/widget_editor.pt"
   />
 
+  <vocabulary
+     name="Widgets"
+     factory=".widget.WidgetsVocabulary"
+  />
 
   <!-- Effect -->
 

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py  
Sat Nov  5 15:25:24 2005
@@ -21,6 +21,7 @@
 from zope.app.container.interfaces import IContainer
 from zope.app.traversing.interfaces import ITraversable
 from zope.interface import implements
+from zope.interface.interfaces import IInterface
 
 from cpsskins.elements.format import Format
 from cpsskins.elements.interfaces import IFormat
@@ -40,6 +41,9 @@
     def getLayoutType():
        """Return the layout type"""
 
+class ILayoutType(IInterface):
+    """The layout type categorizes layout elements."""
+
 class Layout(Format, BTreeContainer):
     """A layout is used to format layout elements (cells, blocks, etc)
 

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py  
Sat Nov  5 15:25:24 2005
@@ -18,11 +18,13 @@
 __docformat__ = "reStructuredText"
 
 from persistent import Persistent
-from zope.component import getUtility
+from zope.component import getUtility, getUtilitiesFor
 from zope.configuration.fields import GlobalObject
-from zope.interface import implements
+from zope.interface import implements, Attribute
+from zope.interface.interfaces import IInterface
 from zope.i18nmessageid import MessageFactory
 from zope.schema import Choice, TextLine
+from zope.schema.vocabulary import SimpleVocabulary
 
 from cpsskins.configuration.interfaces import IRegistry
 from cpsskins.elements.interfaces import IFormat
@@ -39,27 +41,17 @@
     id = Choice(
         title=_("Widget"),
         description=_("A widget for displaying content"),
-        vocabulary="WidgetsByType",
+        vocabulary="Widgets",
         )
- 
+
     # TODO: to refactor
     title = TextLine(
         title=_("Widget title"),
         )
 
-    type = GlobalObject(
-        title=_("Widget type"),
-        )
-
-    factory = GlobalObject(
-        title=_("Widget factory"),
-        )
+    type = Attribute(u"Widget type")
 
-    def getWidgetId():
-       """Return the widget id"""
-
-    def getWidgetType():
-       """Return the widget type"""
+    factory = Attribute(u"Widget factory")
 
 class Widget(Format, Persistent):
     """A presentation element is used to present data with help of widgets.
@@ -70,18 +62,19 @@
     """
     implements(IWidget)
 
-    def __init__(self, id='', title=u'', type=None, factory=None):
+    def __init__(self, id=u'', title=u'', type=None, factory=None):
         self.id = id
         self.title = title
         self.type = type
         self.factory = factory
 
     def __repr__(self):
-        return "Widget('%s')" % self.getWidgetId()
-
-    def getWidgetType(self):
-        widget = getUtility(IWidget, self.getWidgetId())
-        return widget.type
+        return "Widget('%s')" % self.id
 
-    def getWidgetId(self):
-        return self.id
+def WidgetsVocabulary(context):
+    """A vocabulary that contains the list of widgets in a given category.
+    """
+    widgets = []
+    for id, widget in list(getUtilitiesFor(IWidget)):
+        widgets.append((_(widget.title), id))
+    return SimpleVocabulary.fromItems(widgets)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to