Author: jmorliaguet
Date: Mon Nov  7 22:39:22 2005
New Revision: 29226

Added:
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/meta.zcml   
(contents, props changed)
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/metaconfigure.py
   (contents, props changed)
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/metadirectives.py
   (contents, props changed)
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
   (contents, props changed)
   z3lab/cpsskins/branches/jmo-perspectives/engines/default/perspectives.zcml   
(contents, props changed)
Modified:
   z3lab/cpsskins/branches/jmo-perspectives/configuration/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/configuration/meta.zcml
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py
   z3lab/cpsskins/branches/jmo-perspectives/engines/README.txt
   z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt
   z3lab/cpsskins/branches/jmo-perspectives/engines/default/configure.zcml
Log:

- perspectives are registered as global utilities



Modified: z3lab/cpsskins/branches/jmo-perspectives/configuration/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configuration/__init__.py  
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configuration/__init__.py  Mon Nov 
 7 22:39:22 2005
@@ -30,6 +30,7 @@
 from formats.format import IFormat, Format
 from filters.filter import IFilter, Filter
 from presentations.presentation import IPresentation, Presentation
+from perspectives.perspective import IPerspective, Perspective
 from renderers.renderer import IRenderer, Renderer
 from widgets.widget import IWidget, Widget
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/configuration/meta.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configuration/meta.zcml    
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configuration/meta.zcml    Mon Nov 
 7 22:39:22 2005
@@ -12,6 +12,8 @@
 
   <include package=".presentations" file="meta.zcml" />
 
+  <include package=".perspectives" file="meta.zcml" />
+
   <include package=".displays" file="meta.zcml" />
 
   <include package=".formats" file="meta.zcml" />

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/__init__.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/__init__.py 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/__init__.py 
    Mon Nov  7 22:39:22 2005
@@ -11,9 +11,10 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""Rendering engine traverser /++engine++name
 
 $Id$
 """
+
 __docformat__ = "reStructuredText"
 

Added: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/meta.zcml
==============================================================================
--- (empty file)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/meta.zcml   
    Mon Nov  7 22:39:22 2005
@@ -0,0 +1,13 @@
+
+<configure xmlns="http://namespaces.zope.org/meta";>
+
+  <directives namespace="http://namespaces.zope.org/cpsskins";>
+
+    <directive
+       name="perspective"
+       schema=".metadirectives.IPerspectiveDirective"
+       handler=".metaconfigure.perspective" />
+
+  </directives>
+
+</configure>

Added: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/metaconfigure.py
==============================================================================
--- (empty file)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/metaconfigure.py
        Mon Nov  7 22:39:22 2005
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# Copyright (c) 2005 Nuxeo and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+from zope.component import queryUtility, provideUtility
+from zope.configuration.exceptions import ConfigurationError
+
+from cpsskins import configuration
+
+def perspective(_context, name=u'', title=u''):
+
+    if queryUtility(configuration.IPerspective, name) is not None:
+        raise ConfigurationError(
+            "The '%s' perspective has already been registered." % name)
+
+    provideUtility(configuration.Perspective(name=name, title=title),
+                   configuration.IPerspective, name)

Added: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/metadirectives.py
==============================================================================
--- (empty file)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/metadirectives.py
       Mon Nov  7 22:39:22 2005
@@ -0,0 +1,40 @@
+##############################################################################
+#
+# Copyright (c) 2005 Nuxeo and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+from zope.interface import Interface
+from zope.i18nmessageid import MessageFactory
+from zope.schema import DottedName, TextLine
+
+_ = MessageFactory("cpsskins")
+
+class IPerspectiveDirective(Interface):
+
+    name = DottedName(
+        title=_("Name"),
+        description=_("The name of the perspective."),
+        required=False,
+        min_dots=1,
+        )
+
+    title = TextLine(
+        title=_("Title"),
+        description=_("The title of the perspective."),
+        required=False,
+        )
+

Added: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
==============================================================================
--- (empty file)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
  Mon Nov  7 22:39:22 2005
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2005 Nuxeo and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+__docformat__ = "reStructuredText"
+
+from zope.interface import implements, Interface
+
+class IPerspective(Interface):
+    """A perspective."""
+
+class Perspective(object):
+
+    implements(IPerspective)
+
+    def __init__(self, name, title):
+        self.name = name 
+        self.title = title
+

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py  (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py  Mon Nov  7 
22:39:22 2005
@@ -22,6 +22,7 @@
 from zope.component import adapts, queryUtility, getUtilitiesFor
 from zope.interface import implements
 
+from cpsskins import configuration
 from cpsskins.elements.interfaces import INode, INodeTraverser
 from cpsskins.perspectives.interfaces import IPerspective
 from cpsskins.storage.interfaces import IPerspectiveStorage
@@ -85,11 +86,7 @@
             return v
 
     def getPerspectiveById(self, id):
-        perspectives = self.getStorage(IPerspectiveStorage)
-        for p in perspectives.values():
-            if str(p) == id:
-                return p
-        return queryUtility(IPerspective, id)
+        return queryUtility(configuration, IPerspective, id)
 
     def addPerspective(self, object):
         """Add a perspective to the perspective storage
@@ -100,9 +97,10 @@
         perspectives[name] = object
 
     def listPerspectives(self):
-        perspectives = self.getStorage(IPerspectiveStorage)
-        return [str(p) for p in perspectives.values()] \
-             + [p[0] for p in list(getUtilitiesFor(IPerspective))]
+        info = []
+        for name, object in getUtilitiesFor(configuration.IPerspective):
+            info.append({'name': object.name, 'title': object.title})
+        return info
 
 class NodeTraverser(object):
     """This adapter makes theme nodes traversable.

Modified: z3lab/cpsskins/branches/jmo-perspectives/engines/README.txt
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/engines/README.txt (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/engines/README.txt Mon Nov  7 
22:39:22 2005
@@ -26,6 +26,8 @@
 
 - accesskeys.zcml (the access keys defined by the engine)
 
+- perspectives.zcml (the perspectives defined by the engine)
+
 - filters/ (the filters defined by the engine)
 
 - formats/ (the formats defined by the engine)

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring.py     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring.py     
Mon Nov  7 22:39:22 2005
@@ -61,7 +61,7 @@
         viewer = getMultiAdapter((self.context, self.request), IViewer)
         return viewer(**kw)
 
-    def setPerspective(self, perspective=''):
+    def setPerspective(self, perspective=u''):
         """Set the perspective
         """
         pkg_id = 'cpsskins'

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt  
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt  
    Mon Nov  7 22:39:22 2005
@@ -48,9 +48,9 @@
     <select onchange="submit()" name="perspective">
       <option value="" i18n:translate="">default</option>
       <option tal:repeat="perspective perspectives"
-              tal:content="perspective"
-              tal:attributes="value perspective;
-                              selected python:perspective == current
+              tal:content="perspective/title"
+              tal:attributes="value perspective/name;
+                              selected python:perspective['name'] == current
                                        and 'selected' or nothing" />
     </select>
   </form>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/engines/default/configure.zcml     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/engines/default/configure.zcml     
Mon Nov  7 22:39:22 2005
@@ -5,6 +5,10 @@
 
   <include file="accesskeys.zcml" />
 
+  <!-- Perspectives -->
+
+  <include file="perspectives.zcml" />
+
 
   <!-- Default engine's formats -->
 

Added: 
z3lab/cpsskins/branches/jmo-perspectives/engines/default/perspectives.zcml
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/engines/default/perspectives.zcml  
Mon Nov  7 22:39:22 2005
@@ -0,0 +1,9 @@
+<configure
+    xmlns="http://namespaces.zope.org/cpsskins";>
+
+  <perspective
+      name="cpsskins.frontpage"
+      title="Front page"
+  />
+
+</configure>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to