Author: jmorliaguet Date: Mon Mar 27 21:11:56 2006 New Revision: 2736 Modified: cpsskins/branches/jmo-perspectives/elements/configure.zcml cpsskins/branches/jmo-perspectives/elements/interfaces.py cpsskins/branches/jmo-perspectives/io/README.txt cpsskins/branches/jmo-perspectives/io/interfaces.py cpsskins/branches/jmo-perspectives/thememanager.py Log:
- more work on URIs Modified: cpsskins/branches/jmo-perspectives/elements/configure.zcml ============================================================================== --- cpsskins/branches/jmo-perspectives/elements/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/elements/configure.zcml Mon Mar 27 21:11:56 2006 @@ -405,7 +405,7 @@ <interface interface=".interfaces.IPortlet" - type=".interfaces.IElementType" + type="cpsskins.setup.interfaces.IResourceType" /> <cpsskins:presentation Modified: cpsskins/branches/jmo-perspectives/elements/interfaces.py ============================================================================== --- cpsskins/branches/jmo-perspectives/elements/interfaces.py (original) +++ cpsskins/branches/jmo-perspectives/elements/interfaces.py Mon Mar 27 21:11:56 2006 @@ -178,7 +178,7 @@ # The actual elements -class IPortlet(ILeaf): +class IPortlet(ICanvas, ILeaf): """A base portlet interface implemented by all portlets (global or local) """ Modified: cpsskins/branches/jmo-perspectives/io/README.txt ============================================================================== --- cpsskins/branches/jmo-perspectives/io/README.txt (original) +++ cpsskins/branches/jmo-perspectives/io/README.txt Mon Mar 27 21:11:56 2006 @@ -7,12 +7,14 @@ This package contains XML exporters and importers. -Resources must be uniquely identifiable to be exported or imported. +To be exported and imported, resources must be uniformally identifiable. -Their name is obtained from a combination of element, resource and content -type names. +Their name is obtained by combining element type, resource type and content +type names. Finally the resource's own identifier is used. + >>> from zope.app.testing import ztapi + Classification of resources =========================== @@ -23,25 +25,23 @@ 1) Element types ---------------- -Element types provide a first-level categorization of resources. - -- 'portlet' +Element types provide a first-level categorization of resources: -- 'display' +- 'canvas' (contains all elements that can be put on the canvas) -- 'format' +- 'display' (contains all elements that can be displayed) -- 'canvas' +- 'format' (contains all elements that can be formatted) -- 'perspective' +- 'engine' - 'filter' -- 'engine' +- 'perspective' -The element name of a given resource is obtained from the "IElementType" -interface: +The element type of a given resource is obtained by querying the resource's +IElementType. >>> from zope.app.interface import queryType @@ -53,7 +53,7 @@ >>> element_type.getTaggedValue('name') u'canvas' -or more simply: +or more succintly: >>> from cpsskins.elements.interfaces import IType >>> IType(resource).elementname @@ -65,14 +65,14 @@ Resource types provide a second-level categorization of resources. -- displays: 'box', 'area', 'boxgroup' +- 'box', 'area', 'boxgroup' (display elements) -- formats: 'widget', 'style', 'effect', 'layout', ... +- 'widget', 'style', 'effect', 'layout' (format elements) -- perspectives: 'perspective' +- 'portlet', 'cell', 'slot' (canvas element) -The resource name of a given resource is obtained from the "IResourceType" -interface: +The resource type of a given resource is obtained by querying the resource's +IResourceType. >>> from cpsskins.setup.interfaces import IResourceType >>> from cpsskins.ui.standard.formats.style import Style @@ -92,16 +92,17 @@ ---------------- Content types provide a third-level categorization of resources. -Typically they are third-party resources. + +Typically they are used to identify third-party resources when the element +type and the resource type are not specific enough. - 'cpsskins.actions', 'cpsskins.breadcrumbs', ... The content type is identical to the resource type for resources that have no third-level type of categorization (i.e. perpective, theme, ...) - -The content name of a given resource is obtained from the "IContentType" -interface: +The content type of a given resource is obtained by querying the resource's +IContentType. >>> from zope.app.content.interfaces import IContentType >>> from cpsskins.portlets.actions.portlet import Actions @@ -122,29 +123,39 @@ To identify resources, a URI (Uniform Resource Identifier) is used. A URI consists of a combination of the element type, resource type and content -type separated with a '-'. +type separated with a '-' sign. + +The last part of the URI is the element's identifier as it is used in a +relation (cf. cpsskins.relations.interfaces.IRelatable). -For instance a portlet will be identified as: + >>> from cpsskins.relations.interfaces import IRelatable + >>> from cpsskins.elements.interfaces import IElement - 'canvas-portlet-cpsskins.actions-123456' + >>> class Relatable(object): + ... def __init__(self, element): + ... self.element = element + ... def __str__(self): + ... return '12345' -elementname - resourcename - id -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + >>> ztapi.provideAdapter(IElement, IRelatable, Relatable) -Example: + >>> resource = Style() + >>> str(IRelatable(resource)) + '12345' - 'format-style', 'format-widget' +For instance a portlet will be uniformally identified as: >>> from cpsskins.elements.interfaces import IIdentifiable + >>> resource = Actions() - >>> resource = Style() >>> IIdentifiable(resource).getURI() - u'format-style-' + u'canvas-portlet-cpsskins.actions-12345' -elementname - resourcename - contentname - id -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If the resource type is the same as the content type, the name is written only +once: -Example: + >>> resource = Style() + >>> IIdentifiable(resource).getURI() + u'format-style-12345' - 'portlet-cpsskins.actions', 'canvas-slot' Modified: cpsskins/branches/jmo-perspectives/io/interfaces.py ============================================================================== --- cpsskins/branches/jmo-perspectives/io/interfaces.py (original) +++ cpsskins/branches/jmo-perspectives/io/interfaces.py Mon Mar 27 21:11:56 2006 @@ -29,7 +29,7 @@ """Return some export information (dictionary, ...)""" class IDataImporter(Interface): - """A data import is used to import data from XML + """A data importer is used to import data from XML """ def load(xml): """Load data from XML.""" Modified: cpsskins/branches/jmo-perspectives/thememanager.py ============================================================================== --- cpsskins/branches/jmo-perspectives/thememanager.py (original) +++ cpsskins/branches/jmo-perspectives/thememanager.py Mon Mar 27 21:11:56 2006 @@ -117,7 +117,8 @@ if id is None: id = intids.register(element) else: - logger.debug("The element %s is already registered", repr(element)) + logger.debug("The element %s is already registered. " + "No need to register it again.", repr(element)) # store the element's id in the element itself. element.identifier = id return id -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins