Author: jmorliaguet
Date: Sun Dec 11 20:15:00 2005
New Revision: 2015

Added:
   cpsskins/branches/jmo-perspectives/configuration/predicates/
Modified:
   cpsskins/branches/jmo-perspectives/configuration/formats/metaconfigure.py
   cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py
   cpsskins/branches/jmo-perspectives/configuration/settings/metaconfigure.py
   cpsskins/branches/jmo-perspectives/elements/element.py
   cpsskins/branches/jmo-perspectives/elements/interfaces.py
   cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py
   cpsskins/branches/jmo-perspectives/engines/default/filters/style/jsonrpc.py
   cpsskins/branches/jmo-perspectives/engines/default/formats/effect.py
   cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py
   cpsskins/branches/jmo-perspectives/engines/default/formats/style.py
   cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py
   cpsskins/branches/jmo-perspectives/io/README.txt
   cpsskins/branches/jmo-perspectives/io/relation.py
   cpsskins/branches/jmo-perspectives/perspectives/interfaces.py
Log:

- added a 'name' tagged value to all IElement interfaces

- elements are identifiable by URI



Modified: 
cpsskins/branches/jmo-perspectives/configuration/formats/metaconfigure.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/formats/metaconfigure.py   
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/formats/metaconfigure.py   
Sun Dec 11 20:15:00 2005
@@ -80,5 +80,4 @@
     alsoProvides(IFormat, IElementType)
 
     # set tagged values
-    schema.setTaggedValue('name', name)
     schema.setTaggedValue('predicate', predicate)

Modified: 
cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py  
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py  
Sun Dec 11 20:15:00 2005
@@ -102,3 +102,4 @@
 
     # set up interface types
     alsoProvides(schema, IContentType)
+    schema.setTaggedValue('name', name)

Modified: 
cpsskins/branches/jmo-perspectives/configuration/settings/metaconfigure.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/settings/metaconfigure.py  
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/settings/metaconfigure.py  
Sun Dec 11 20:15:00 2005
@@ -41,5 +41,4 @@
 
     provideUtility(factory, IFactory, name)
     alsoProvides(schema, IResourceType)
-    schema.setTaggedValue('name', name)
 

Modified: cpsskins/branches/jmo-perspectives/elements/element.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/element.py      (original)
+++ cpsskins/branches/jmo-perspectives/elements/element.py      Sun Dec 11 
20:15:00 2005
@@ -31,6 +31,7 @@
 from cpsskins.elements.interfaces import IInnerNode, ILeaf, INodeTraverser
 from cpsskins.elements.interfaces import IIdentifiable
 from cpsskins.relations.interfaces import IRelatable
+from cpsskins.setup.interfaces import IResourceType
 
 class Element(Contained):
     """An element
@@ -56,18 +57,19 @@
         return str(id)
 
 class Identifiable(object):
-    """This adapter makes elements identifiable.
+    """This adapter makes resources uniquely identifiable.
     """
-    adapts(IElement)
     implements(IIdentifiable)
 
     def __init__(self, element):
         self.element = element
 
-    def getIdentifier(self):
+    def getURI(self):
         element = self.element
-        return str(IRelatable(element)) or \
-               str(IRelatable(element.__parent__)) or u''
+        prefix = queryType(element, IResourceType).getTaggedValue('name')
+        suffix = str(IRelatable(element)) or \
+                 str(IRelatable(element.__parent__)) or u''
+        return '%s.%s' % (prefix, suffix)
 
 class Node(Element):
     """A Node is an element in a tree structure.
@@ -134,8 +136,14 @@
     def getElementType(self):
         return queryType(self.element, IElementType)
 
+    def getResourceType(self):
+        return queryType(self.element, IResourceType)
+
     def contenttype(self):
-        return self.getContentType().__name__
+        return self.getContentType().getTaggedValue('name')
 
     def elementtype(self):
-        return self.getElementType().__name__
+        return self.getElementType().getTaggedValue('name')
+
+    def resourcetype(self):
+        return self.getResourceType().getTaggedValue('name')

Modified: cpsskins/branches/jmo-perspectives/elements/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/interfaces.py   (original)
+++ cpsskins/branches/jmo-perspectives/elements/interfaces.py   Sun Dec 11 
20:15:00 2005
@@ -35,9 +35,8 @@
 
 class IIdentifiable(Interface):
 
-    def getIdentifier():
-        """Return the element's identifier which can be a unique
-        identifer or a name depending of the usage context.
+    def getURI():
+        """Return the element's unique identifier.
         """
 
 class IType(Interface):
@@ -72,6 +71,8 @@
 class IDisplay(IElement):
     """A display element"""
 
+IDisplay.setTaggedValue('name', u'display')
+
 class IDisplayable(Interface):
 
     def getDisplay(perspective, default):
@@ -118,6 +119,8 @@
     def findDisplays():
         """ """
 
+IFormat.setTaggedValue('name', u'format')
+
 class IFormattable(Interface):
 
     def getFormats(name, resolve):
@@ -163,17 +166,9 @@
     def uncustomizeFormat(name, perspective):
         """ """
 
-# The different categories of elements
-
-class ICanvas(IInnerNode):
-    pass
-
-class IContent(ILeaf):
-    pass
-
 # The actual elements
 
-class IPortlet(IContent):
+class IPortlet(ILeaf):
     """A base portlet interface implemented by all portlets (global or local)
     """
 
@@ -183,8 +178,10 @@
 
     def __call__(info):
         """Return the portlet's data to display"""
+ 
+IPortlet.setTaggedValue('name', u'portlet')
 
-class ISlot(ICanvas, IItemContainer):
+class ISlot(IInnerNode, IItemContainer):
     """A slot.
     """
 
@@ -201,21 +198,27 @@
     def __str__():
         """Returns the slot's name."""
 
-class ICell(ICanvas):
+ISlot.setTaggedValue('name', u'slot')
+
+class ICell(IInnerNode):
     """A cell.
     """
     title = TextLine(
         title=_(u"Cell's title"),
         required=False)
 
-class IPageBlock(ICanvas):
+ICell.setTaggedValue('name', u'cell')
+
+class IPageBlock(IInnerNode):
     """A page block.
     """
     title = TextLine(
         title=_(u"Page block's title"),
         required=False)
 
-class IThemePage(ICanvas):
+IPageBlock.setTaggedValue('name', u'pageblock')
+
+class IThemePage(IInnerNode):
     """A page.
     """
     title = TextLine(
@@ -226,7 +229,9 @@
         """Return true if the page is the default one.
         """
 
-class ITheme(ICanvas):
+IThemePage.setTaggedValue('name', u'themepage')
+
+class ITheme(IInnerNode):
     """A theme.
     """
 
@@ -249,6 +254,8 @@
         """Set the theme as the default theme.
         """
 
+ITheme.setTaggedValue('name', u'theme')
+
 # theme objects
 class IElementContainer(IOrderedContainer):
     pass

Modified: 
cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py    
    (original)
+++ 
cpsskins/branches/jmo-perspectives/engines/default/filters/style/__init__.py    
    Sun Dec 11 20:15:00 2005
@@ -130,7 +130,7 @@
         self.style = style
 
     def __str__(self):
-        return 'style%s' % IIdentifiable(self.style).getIdentifier()
+        return 'style%s' % IIdentifiable(self.style).getURI()
 
     def __call__(self):
         """Render the style in CSS"""

Modified: 
cpsskins/branches/jmo-perspectives/engines/default/filters/style/jsonrpc.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/default/filters/style/jsonrpc.py 
(original)
+++ cpsskins/branches/jmo-perspectives/engines/default/filters/style/jsonrpc.py 
Sun Dec 11 20:15:00 2005
@@ -85,5 +85,5 @@
         """Render a style preview based on the specified widget"""
 
         widget = getUtility(configuration.IWidget, widget_type)
-        return widget.factory(None, None).renderPreview()
+        return widget.view(None, None).renderPreview()
 

Modified: cpsskins/branches/jmo-perspectives/engines/default/formats/effect.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/default/formats/effect.py        
(original)
+++ cpsskins/branches/jmo-perspectives/engines/default/formats/effect.py        
Sun Dec 11 20:15:00 2005
@@ -62,6 +62,8 @@
         default=True,
         required=False)
 
+IEffect.setTaggedValue('name', u'effect')
+
 class Effect(Format, Persistent):
     """Image processing effect.
     """

Modified: cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py        
(original)
+++ cpsskins/branches/jmo-perspectives/engines/default/formats/layout.py        
Sun Dec 11 20:15:00 2005
@@ -36,6 +36,8 @@
     def traverse(name, remaining):
        """Get a layout attribute by traversal."""
 
+ILayout.setTaggedValue('name', u'layout')
+
 class Layout(Format, PersistentMapping):
     """A layout is used to format layout elements (cells, blocks, etc)
 

Modified: cpsskins/branches/jmo-perspectives/engines/default/formats/style.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/default/formats/style.py 
(original)
+++ cpsskins/branches/jmo-perspectives/engines/default/formats/style.py Sun Dec 
11 20:15:00 2005
@@ -35,6 +35,8 @@
 class IStyle(IFormat, IMapping):
     """A style"""
 
+IStyle.setTaggedValue('name', u'style')
+
 class Style(Format, PersistentMapping):
     """A style is a collection of properties
 

Modified: cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py        
(original)
+++ cpsskins/branches/jmo-perspectives/engines/default/formats/widget.py        
Sun Dec 11 20:15:00 2005
@@ -43,6 +43,8 @@
         vocabulary="Widgets",
         )
 
+IWidget.setTaggedValue('name', u'widget')
+
 class Widget(Persistent, Format):
     """A presentation element is used to present data with help of widgets.
 

Modified: cpsskins/branches/jmo-perspectives/io/README.txt
==============================================================================
--- cpsskins/branches/jmo-perspectives/io/README.txt    (original)
+++ cpsskins/branches/jmo-perspectives/io/README.txt    Sun Dec 11 20:15:00 2005
@@ -6,3 +6,28 @@
 ===============
 
 This package contains XML exporters and importers.
+
+URI
+---
+
+To identify resources a URI (Uniform Resource Identifier) is used
+
+A URI consists of a prefix and a suffix separated by a '.' character.
+
+The prefix is a short name that represents a category of resources and that
+defines a namespace. The suffix identifies the resource inside the namespace.
+
+For instance a portlet will be identified as:
+
+  portlet.my-portlet
+
+or:
+
+  portlet.123456
+
+The prefix for a given resource is obtained from the "IResourceType" interface
+as a tagged value called 'name':
+
+  resource_type = queryType(resource, IResourceType)
+  prefix = resource_type.getTaggedValue('name')
+

Modified: cpsskins/branches/jmo-perspectives/io/relation.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/io/relation.py   (original)
+++ cpsskins/branches/jmo-perspectives/io/relation.py   Sun Dec 11 20:15:00 2005
@@ -21,9 +21,9 @@
 from zope.component import adapts
 from zope.interface import implements
 
+from cpsskins.elements.interfaces import IIdentifiable
 from cpsskins.relations.interfaces import IRelation
 from cpsskins.io.interfaces import IDataExporter, IDataImporter
-from zope.app.location.traversing import LocationPhysicallyLocatable
 
 class Exporter(object):
     """This view is used to exports relations to XML
@@ -45,7 +45,7 @@
 
         for relate in context:
             relate_info.append({
-                'uri': zapi.name(relate),
+                'uri': IIdentifiable(relate).getURI(),
                 })
 
         return {

Modified: cpsskins/branches/jmo-perspectives/perspectives/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/perspectives/interfaces.py       
(original)
+++ cpsskins/branches/jmo-perspectives/perspectives/interfaces.py       Sun Dec 
11 20:15:00 2005
@@ -20,7 +20,9 @@
 from zope.interface import Interface
 from zope.schema import DottedName, TextLine
 
-class IPerspective(Interface):
+from cpsskins.elements.interfaces import IElement
+
+class IPerspective(IElement):
     """A perspective."""
 
     name = DottedName(
@@ -34,3 +36,4 @@
     def __str__(self):
         """Return the name of the perspective"""
 
+IPerspective.setTaggedValue('name', u'perspective')
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to