Author: jmorliaguet
Date: Wed Nov  9 22:17:07 2005
New Revision: 29399

Modified:
   
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/presentation_editor.pt
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
   z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/display.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py
   z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/perspectives/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/perspectives/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/perspectives/interfaces.py
Log:

- unification between perspective configuration item and instances



Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/presentation_editor.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/presentation_editor.pt 
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/presentation_editor.pt 
    Wed Nov  9 22:17:07 2005
@@ -35,7 +35,7 @@
                             perspective_name perspective/name|nothing;
                             perspective_is_current python: perspective == 
current_perspective;
                             current_formats python: current_perspective and 
-                                            
views[str(current_perspective)]['formats'] or []"
+                                            
views[current_perspective.name]['formats'] or []"
                 tal:attributes="class python: even and 'even' or nothing">
 
               <td tal:content="view" />

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
  Wed Nov  9 22:17:07 2005
@@ -17,7 +17,7 @@
   </content>
 
   <adapter
-      factory=".perspective.Relatable"
+      factory=".perspective.Element"
   />
 
 </configure>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
  Wed Nov  9 22:17:07 2005
@@ -22,10 +22,10 @@
 from zope.interface import implements, Interface
 from zope.schema import DottedName, TextLine
 
-from cpsskins.relations.interfaces import IRelatable
+from cpsskins import interfaces
 
 class IPerspective(Interface):
-    """A perspective."""
+    """A perspective configuration item."""
 
     name = DottedName(
         title=u"Name",
@@ -36,22 +36,30 @@
         )
 
 class Perspective(object):
-
+    """A perspective configuration item.
+    """
     implements(IPerspective)
 
     def __init__(self, name, title):
         self.name = name 
         self.title = title
 
-class Relatable(object):
-    """This adapter makes perspectives relatable.
+class Element(object):
+    """This adapter turns perspective configuration items into elements that
+    can natively be used by the application.
     """
     adapts(IPerspective)
-    implements(IRelatable)
+    implements(interfaces.IPerspective)
 
     def __init__(self, context):
         self.context = context
 
-    def __str__(self):
-        """The perspective's name is used as an identifier."""
+    def name(self):
         return self.context.name
+
+    def title(self):
+        return self.context.title
+
+    name = property(name)
+
+    title = property(title)

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py       
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py       Wed Nov 
 9 22:17:07 2005
@@ -22,7 +22,6 @@
 
 from cpsskins.controllers import Controller
 from cpsskins.configuration.interfaces import IRegistry
-from cpsskins.perspectives import SitePerspective
 from cpsskins.thememanager import getThemeManager
 from interfaces import IController
 
@@ -46,7 +45,3 @@
         if tmutil.getDefaultTheme() is None:
             tmutil.setAsDefault(element)
 
-        # XXX for testing
-        for id in ('front page', 'section', 'subsection'):
-            element.addPerspective(SitePerspective(id))
-

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/display.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/display.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/display.py        Wed Nov 
 9 22:17:07 2005
@@ -175,7 +175,7 @@
                 second=display,
                 )
         else:
-            if not configuration.IPerspective.providedBy(perspective):
+            if not IPerspective.providedBy(perspective):
                 raise ValueError("%s is not a perspective" % repr(perspective))
             relation = TriadicRelation(
                 predicate=hasDisplayFromPerspective,

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  Wed Nov  9 
22:17:07 2005
@@ -23,7 +23,7 @@
 from zope.interface import implements
 
 from cpsskins import configuration
-from cpsskins.elements.interfaces import INode, INodeTraverser
+from cpsskins.elements.interfaces import IElement, INode, INodeTraverser
 from cpsskins.perspectives.interfaces import IPerspective
 from cpsskins.storage.interfaces import IPerspectiveStorage
 from cpsskins.thememanager import getThemeManager
@@ -86,7 +86,8 @@
             return v
 
     def getPerspectiveById(self, id):
-        return queryUtility(configuration.IPerspective, id)
+        """Return a perspective by id."""
+        return IPerspective(queryUtility(configuration.IPerspective, id))
 
     def addPerspective(self, object):
         """Add a perspective to the perspective storage

Modified: z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      Wed Nov  9 
22:17:07 2005
@@ -21,7 +21,7 @@
 from zope.app.cache.interfaces.ram import IRAMCache
 from zope.i18nmessageid import MessageFactory
 
-from cpsskins.elements.interfaces import IPortlet, IDisplay, IFormat
+from cpsskins.elements.interfaces import IElement, IPortlet, IDisplay, IFormat
 from cpsskins.perspectives.interfaces import IPerspective
 
 _ = MessageFactory("cpsskins")

Modified: z3lab/cpsskins/branches/jmo-perspectives/perspectives/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/perspectives/__init__.py   
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/perspectives/__init__.py   Wed Nov 
 9 22:17:07 2005
@@ -20,44 +20,37 @@
 from persistent import Persistent
 from zope.interface import implements
 
-from interfaces import IPerspective, ISitePerspective
+from interfaces import IPerspective
 
 class Perspective(object):
     """A perspective
 
-    >>> perspective = Perspective('Some perspective')
+    >>> perspective = Perspective(name='cpsskins.perspective')
     >>> perspective
-    <Perspective: 'Some perspective'>
+    <Perspective: 'cpsskins.perspective'>
 
     """
     implements(IPerspective)
 
-    def __init__(self, perspective=''):
-        self._perspective = perspective
+    def __init__(self, name=u'', title=u''):
+        self.name = name
+        self.title = title
 
     def __repr__(self):
-        return "<Perspective: '%s'>" % self._perspective
+        return "<Perspective: '%s'>" % str(self)
 
     def __str__(self):
-        return self._perspective
+        return self.name
 
     def __eq__(self, other):
         return str(self) == other
 
 
-class SitePerspective(Persistent, Perspective):
-    """A site perspective is a persistent perspective.
-    """
-    implements(ISitePerspective)
-
-    def __repr__(self):
-        return "<Site perspective: '%s'>" % self._perspective
-
 class Relatable(object):
     """This adapter makes perspectives relatable.
     """
-    def __init__(self, perspective):
-        self.perspective = perspective
+    def __init__(self, context):
+        self.context = context
 
     def __str__(self):
-        return str(self.perspective)
+        return str(self.context)

Modified: z3lab/cpsskins/branches/jmo-perspectives/perspectives/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/perspectives/configure.zcml        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/perspectives/configure.zcml        
Wed Nov  9 22:17:07 2005
@@ -26,19 +26,4 @@
 
   </content>
 
-
-  <content class=".SitePerspective">
-
-    <require
-        permission="zope.View"
-        interface=".interfaces.ISitePerspective"
-        />
-
-    <require
-        permission="zope.ManageContent"
-        set_schema=".interfaces.ISitePerspective"
-        />
-
-  </content>
-
 </configure>

Modified: z3lab/cpsskins/branches/jmo-perspectives/perspectives/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/perspectives/interfaces.py 
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/perspectives/interfaces.py Wed Nov 
 9 22:17:07 2005
@@ -25,6 +25,3 @@
     def __str__(self):
         """Return the name of the perspective"""
 
-class ISitePerspective(IPerspective):
-    """A perspective."""
-
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to