Author: jmorliaguet
Date: Wed Apr 26 23:30:12 2006
New Revision: 2969

Modified:
   cpsskins/branches/paris-sprint-2006/browser/rendering/renderer.py
   cpsskins/branches/paris-sprint-2006/configuration/displays/metaconfigure.py
   cpsskins/branches/paris-sprint-2006/configuration/fields/metaconfigure.py
   cpsskins/branches/paris-sprint-2006/configuration/formats/metaconfigure.py
   cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py
   
cpsskins/branches/paris-sprint-2006/configuration/presentations/metaconfigure.py
   cpsskins/branches/paris-sprint-2006/configuration/renderers/metaconfigure.py
   cpsskins/branches/paris-sprint-2006/doc/registration.txt
   cpsskins/branches/paris-sprint-2006/elements/display.py
   cpsskins/branches/paris-sprint-2006/elements/element.py
   cpsskins/branches/paris-sprint-2006/elements/interfaces.py
   cpsskins/branches/paris-sprint-2006/elements/presentation.py
   cpsskins/branches/paris-sprint-2006/perspectives/configure.zcml
   cpsskins/branches/paris-sprint-2006/perspectives/interfaces.py
   cpsskins/branches/paris-sprint-2006/setup/README.txt
   cpsskins/branches/paris-sprint-2006/setup/utils.py
   cpsskins/branches/paris-sprint-2006/standard/ds/html.py
   cpsskins/branches/paris-sprint-2006/standard/ds/image.py
   cpsskins/branches/paris-sprint-2006/standard/fields/color.py
   cpsskins/branches/paris-sprint-2006/standard/formats/effect.py
   cpsskins/branches/paris-sprint-2006/standard/formats/layout.py
   cpsskins/branches/paris-sprint-2006/standard/formats/style.py
   cpsskins/branches/paris-sprint-2006/standard/formats/widget.py
Log:

- using the new utility API to register ZCML configuration objects
  (dropped getTaggedValue('name') and setTaggedValue(..))



Modified: cpsskins/branches/paris-sprint-2006/browser/rendering/renderer.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/browser/rendering/renderer.py   
(original)
+++ cpsskins/branches/paris-sprint-2006/browser/rendering/renderer.py   Wed Apr 
26 23:30:12 2006
@@ -88,14 +88,13 @@
         # look for renderers associated to the element's content type
         type = IType(element)
         iface = type.getContentType()
-        name = engine + '.' + iface.getTaggedValue('name')
-        renderer = queryUtility(configuration.IRenderer, name)
+        name = engine + '.renderer'
+        renderer = queryUtility(iface, name)
         if renderer is None:
             # fall back to the element's resource type
             iface = type.getResourceType()
 
-        name = engine + '.' + iface.getTaggedValue('name')
-        renderer = queryUtility(configuration.IRenderer, name)
+        renderer = queryUtility(iface, name)
         if renderer is None:
             logger.warning("The element %s cannot be rendered "
                            "by the %s engine.", repr(element), engine)

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/displays/metaconfigure.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/configuration/displays/metaconfigure.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/configuration/displays/metaconfigure.py 
Wed Apr 26 23:30:12 2006
@@ -74,5 +74,3 @@
     # set up interface types
     alsoProvides(schema, IContentType)
 
-    schema.setTaggedValue('name', name)
-

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/fields/metaconfigure.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/configuration/fields/metaconfigure.py   
(original)
+++ cpsskins/branches/paris-sprint-2006/configuration/fields/metaconfigure.py   
Wed Apr 26 23:30:12 2006
@@ -49,5 +49,3 @@
 
     provideInterface(name, schema, INameType)
 
-    schema.setTaggedValue('name', name)
-

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/formats/metaconfigure.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/configuration/formats/metaconfigure.py  
(original)
+++ cpsskins/branches/paris-sprint-2006/configuration/formats/metaconfigure.py  
Wed Apr 26 23:30:12 2006
@@ -24,12 +24,13 @@
 from zope.app.content.interfaces import IContentType
 from zope.configuration.exceptions import ConfigurationError
 from zope.component import queryUtility, provideUtility
+from zope.component.interface import provideInterface
 from zope.component.interfaces import IFactory
 from zope.interface import alsoProvides
 
 from cpsskins.elements.interfaces import IElementType, IFormat
 from cpsskins.ontology import FormatPredicate, IFormatPredicate
-from cpsskins.setup.interfaces import IResourceType
+from cpsskins.setup.interfaces import IResourceType, INameType
 
 def getAbsolutePath(_context, file):
     return os.path.abspath(str(_context.path(file)))
@@ -80,5 +81,8 @@
     alsoProvides(schema, IResourceType)
     alsoProvides(schema, IContentType)
 
+    provideInterface(name, schema, INameType)
+
     # set tagged values
     schema.setTaggedValue('predicate', predicate)
+

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py 
Wed Apr 26 23:30:12 2006
@@ -93,7 +93,6 @@
 
     # set up interface types
     alsoProvides(schema, IContentType)
-    schema.setTaggedValue('name', name)
 
     provideInterface(name, schema, INameType)
 

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/presentations/metaconfigure.py
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/configuration/presentations/metaconfigure.py
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/configuration/presentations/metaconfigure.py
    Wed Apr 26 23:30:12 2006
@@ -42,9 +42,7 @@
 
     def __call__(self):
 
-        name = self.for_.getTaggedValue('name')
-
-        if queryUtility(configuration.IPresentation, name) is not None:
+        if queryUtility(self.for_, u'presentation') is not None:
             raise ConfigurationError(
                 "A presentation has already been registered for the"
                 "interface %s" % self.for_)
@@ -53,6 +51,5 @@
             raise ConfigurationError("Must specify a display type.")
 
         provideUtility(configuration.Presentation(display=self._display,
-                       formats=self._formats), configuration.IPresentation,
-                       name)
+                       formats=self._formats), self.for_, u'presentation')
 

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/renderers/metaconfigure.py
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/configuration/renderers/metaconfigure.py    
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/configuration/renderers/metaconfigure.py    
    Wed Apr 26 23:30:12 2006
@@ -46,10 +46,10 @@
         engine = self.engine
         renderer(self._context, engine, self.for_)
 
+        name = engine + '.renderer'
         for iface in self.for_:
-            name = engine + '.' + iface.getTaggedValue('name')
-            provideUtility(configuration.Renderer(filters=self.filters),
-                           configuration.IRenderer, name)
+            provideUtility(configuration.Renderer(filters=self.filters), iface,
+                           name)
 
 def renderer(_context, engine, for_):
 

Modified: cpsskins/branches/paris-sprint-2006/doc/registration.txt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/doc/registration.txt    (original)
+++ cpsskins/branches/paris-sprint-2006/doc/registration.txt    Wed Apr 26 
23:30:12 2006
@@ -167,3 +167,25 @@
     >>> [name for name, iface in getUtilitiesFor(INameType) if iface == IDummy]
     [u'dummy']
 
+
+
+Configuration
+-------------
+
+Configuration objects hold parameters associated to a type of object for a
+given name. They are used in ZCML configuration handlers.
+
+    >>> class ISomeType(Interface):
+    ...     """A type of object"""
+
+    >>> class ConfigurationObject(object):
+    ...     """A configuration object"""
+    ...
+    ...     def __init__(self, param):
+    ...         self.param = param
+
+    >>> conf = ConfigurationObject('24')
+    >>> gsm.registerUtility(conf, ISomeType, u'a name')
+
+    >>> gsm.queryUtility(ISomeType, u'a name') is conf
+    True

Modified: cpsskins/branches/paris-sprint-2006/elements/display.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/display.py     (original)
+++ cpsskins/branches/paris-sprint-2006/elements/display.py     Wed Apr 26 
23:30:12 2006
@@ -205,11 +205,11 @@
         """
         context = self.context
 
-        presentation = queryUtility(configuration.IPresentation,
-                                    IType(context).contentname)
+        presentation = queryUtility(IType(context).getContentType(),
+                                    name=u'presentation')
         if presentation is None:
-            presentation = queryUtility(configuration.IPresentation,
-                                        IType(context).elementname)
+            presentation = queryUtility(IType(context).getElementType(),
+                                        name=u'presentation')
 
         display = getUtility(configuration.IDisplay, presentation.display)
         return apply(display.factory, ())

Modified: cpsskins/branches/paris-sprint-2006/elements/element.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/element.py     (original)
+++ cpsskins/branches/paris-sprint-2006/elements/element.py     Wed Apr 26 
23:30:12 2006
@@ -32,6 +32,7 @@
 from cpsskins.elements.interfaces import IIdentifiable, ITypeable
 from cpsskins.relations.interfaces import IRelatable
 from cpsskins.setup.interfaces import IResourceType
+from cpsskins.setup.utils import getTypeName
 
 def uniq(seq):
     set = {}
@@ -169,22 +170,13 @@
         return queryType(self.element, IContentType)
 
     def getElementName(self):
-        type = self.getElementType()
-        if type is not None:
-            return type.getTaggedValue('name')
-        return None
+        return getTypeName(self.getElementType())
 
     def getResourceName(self):
-        type = self.getResourceType()
-        if type is not None:
-            return type.getTaggedValue('name')
-        return None
+        return getTypeName(self.getResourceType())
 
     def getContentName(self):
-        type = self.getContentType()
-        if type is not None:
-            return type.getTaggedValue('name')
-        return None
+        return getTypeName(self.getContentType())
 
     elementname = property(getElementName)
 

Modified: cpsskins/branches/paris-sprint-2006/elements/interfaces.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/interfaces.py  (original)
+++ cpsskins/branches/paris-sprint-2006/elements/interfaces.py  Wed Apr 26 
23:30:12 2006
@@ -85,18 +85,12 @@
 class ICanvas(IElement):
     """A canvas element"""
 
-ICanvas.setTaggedValue('name', u'canvas')
-
 class IDisplay(IElement):
     """A display element"""
 
-IDisplay.setTaggedValue('name', u'display')
-
 class IField(IElement):
     """A field element"""
 
-IField.setTaggedValue('name', u'field')
-
 class IDisplayable(Interface):
 
     def getDisplay(perspective, default):
@@ -141,8 +135,6 @@
     def findDisplays():
         """ """
 
-IFormat.setTaggedValue('name', u'format')
-
 class IFormattable(Interface):
 
     def getFormats(name, resolve):
@@ -202,8 +194,6 @@
     def __call__(info):
         """Return the portlet's data to display"""
  
-IPortlet.setTaggedValue('name', u'portlet')
-
 class ISlot(ICanvas, IInnerNode, IItemContainer):
     """A slot.
     """
@@ -225,8 +215,6 @@
     def __str__():
         """Returns the slot's name."""
 
-ISlot.setTaggedValue('name', u'slot')
-
 class ICell(ICanvas, IInnerNode):
     """A cell.
     """
@@ -234,8 +222,6 @@
         title=_(u"Cell's title"),
         required=False)
 
-ICell.setTaggedValue('name', u'cell')
-
 class IPageBlock(ICanvas, IInnerNode):
     """A page block.
     """
@@ -243,8 +229,6 @@
         title=_(u"Page block's title"),
         required=False)
 
-IPageBlock.setTaggedValue('name', u'pageblock')
-
 class IThemePage(ICanvas, IInnerNode):
     """A page.
     """
@@ -261,8 +245,6 @@
         utility.)
         """
 
-IThemePage.setTaggedValue('name', u'themepage')
-
 class ITheme(ICanvas, IInnerNode):
     """A theme.
     """
@@ -291,8 +273,6 @@
         utility.)
         """
 
-ITheme.setTaggedValue('name', u'theme')
-
 # theme objects
 class IElementContainer(IOrderedContainer):
     pass

Modified: cpsskins/branches/paris-sprint-2006/elements/presentation.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/presentation.py        
(original)
+++ cpsskins/branches/paris-sprint-2006/elements/presentation.py        Wed Apr 
26 23:30:12 2006
@@ -58,11 +58,13 @@
 
         formattable = IFormattable(display)
 
-        factory_info = queryUtility(configuration.IPresentation,
-                                    IType(context).contentname)
+        factory_info = queryUtility(IType(context).getContentType(),
+                                    name=u'presentation')
+
         if factory_info is None:
-            factory_info = queryUtility(configuration.IPresentation,
-                                        IType(context).elementname)
+            factory_info = queryUtility(IType(context).getElementType(),
+                                        name=u'presentation')
+
         for name, types in factory_info.formats.items():
             formattable.addFormat(name=name, types=types)
 

Modified: cpsskins/branches/paris-sprint-2006/perspectives/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/perspectives/configure.zcml     
(original)
+++ cpsskins/branches/paris-sprint-2006/perspectives/configure.zcml     Wed Apr 
26 23:30:12 2006
@@ -27,6 +27,17 @@
       provides="cpsskins.relations.interfaces.IRelatable"
   />
 
+  <interface
+      interface=".interfaces.IPerspective"
+      type="cpsskins.elements.interfaces.IElementType"
+  />
+
+  <interface
+      name="perspective"
+      interface=".interfaces.IPerspective"
+      type="cpsskins.setup.interfaces.INameType"
+  />
+
   <!-- register the 'perspective' setting -->
   <cpsskins:setting
       name="perspective"

Modified: cpsskins/branches/paris-sprint-2006/perspectives/interfaces.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/perspectives/interfaces.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/perspectives/interfaces.py      Wed Apr 
26 23:30:12 2006
@@ -36,4 +36,3 @@
     def __str__(self):
         """Return the name of the perspective"""
 
-IPerspective.setTaggedValue('name', u'perspective')

Modified: cpsskins/branches/paris-sprint-2006/setup/README.txt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/README.txt        (original)
+++ cpsskins/branches/paris-sprint-2006/setup/README.txt        Wed Apr 26 
23:30:12 2006
@@ -335,7 +335,9 @@
 
     >>> resource = Theme()
     >>> element_type = queryType(resource, IElementType)
-    >>> element_type.getTaggedValue('name')
+
+    >>> from cpsskins.setup.utils import getTypeName
+    >>> getTypeName(element_type)
     u'canvas'
 
 or more succintly:
@@ -366,7 +368,7 @@
 
     >>> resource = Style()
     >>> resource_type = queryType(resource, IResourceType)
-    >>> resource_type.getTaggedValue('name')
+    >>> getTypeName(resource_type)
     u'style'
 
 or:
@@ -396,13 +398,13 @@
 
     >>> resource = Actions()
     >>> content_type = queryType(resource, IContentType)
-    >>> content_type.getTaggedValue('name')
-    'standard.actions'
+    >>> getTypeName(content_type)
+    u'standard.actions'
 
 or:
 
     >>> IType(resource).contentname
-    'standard.actions'
+    u'standard.actions'
 
 
 Type signatures

Modified: cpsskins/branches/paris-sprint-2006/setup/utils.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/utils.py  (original)
+++ cpsskins/branches/paris-sprint-2006/setup/utils.py  Wed Apr 26 23:30:12 2006
@@ -62,6 +62,8 @@
     # TODO: could be cached
     names = []
     name_types = list(getUtilitiesFor(INameType))
+    if not isinstance(type, (list , tuple)):
+        type = [type]
     for iface in type:
         name = [k for k, v in list(name_types) if v is iface][0]
         names.append(name)

Modified: cpsskins/branches/paris-sprint-2006/standard/ds/html.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/ds/html.py     (original)
+++ cpsskins/branches/paris-sprint-2006/standard/ds/html.py     Wed Apr 26 
23:30:12 2006
@@ -34,8 +34,6 @@
         required=False,
         )
 
-IHTML.setTaggedValue('name', u'plainhtml')
-
 class HTML(object):
     """Plain HTML content
     """

Modified: cpsskins/branches/paris-sprint-2006/standard/ds/image.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/ds/image.py    (original)
+++ cpsskins/branches/paris-sprint-2006/standard/ds/image.py    Wed Apr 26 
23:30:12 2006
@@ -40,8 +40,6 @@
         required=False,
         )
 
-IImage.setTaggedValue('name', u'image')
-
 class Image(object):
     """An image.
 

Modified: cpsskins/branches/paris-sprint-2006/standard/fields/color.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/fields/color.py        
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/fields/color.py        Wed Apr 
26 23:30:12 2006
@@ -36,8 +36,6 @@
         """RBG representation: rgb(123, 255, 200)
         """
 
-IColor.setTaggedValue('name', u'color')
-
 class Color(Persistent, Element):
     """A web color with red, green and blue components (0-255)
     """

Modified: cpsskins/branches/paris-sprint-2006/standard/formats/effect.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/formats/effect.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/formats/effect.py      Wed Apr 
26 23:30:12 2006
@@ -63,8 +63,6 @@
         default=True,
         required=False)
 
-IEffect.setTaggedValue('name', u'effect')
-
 class Effect(Format, Persistent):
     """Image processing effect.
     """

Modified: cpsskins/branches/paris-sprint-2006/standard/formats/layout.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/formats/layout.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/formats/layout.py      Wed Apr 
26 23:30:12 2006
@@ -37,8 +37,6 @@
     def traverse(name, remaining):
        """Get a layout attribute by traversal."""
 
-ILayout.setTaggedValue('name', u'layout')
-
 class Layout(Format, Persistent):
     """A layout is used to format layout elements (cells, blocks, etc)
 

Modified: cpsskins/branches/paris-sprint-2006/standard/formats/style.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/formats/style.py       
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/formats/style.py       Wed Apr 
26 23:30:12 2006
@@ -36,8 +36,6 @@
 class IStyle(IFormat, IMapping):
     """A style"""
 
-IStyle.setTaggedValue('name', u'style')
-
 class Style(Format, Persistent):
     """A style is a collection of properties
 

Modified: cpsskins/branches/paris-sprint-2006/standard/formats/widget.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/formats/widget.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/formats/widget.py      Wed Apr 
26 23:30:12 2006
@@ -45,8 +45,6 @@
         value_type=Choice(vocabulary='Widgets'),
         )
 
-IWidget.setTaggedValue('name', u'widget')
-
 class Widget(Persistent, Format):
     """A presentation element is used to present data with help of widgets.
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to