Author: jmorliaguet
Date: Fri May  5 22:38:39 2006
New Revision: 3050

Modified:
   cpsskins/branches/paris-sprint-2006/thememanager.py

Log:

- updated the perspective methods to the new registration API



Modified: cpsskins/branches/paris-sprint-2006/thememanager.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/thememanager.py (original)
+++ cpsskins/branches/paris-sprint-2006/thememanager.py Fri May  5 22:38:39 2006
@@ -43,7 +43,7 @@
 from cpsskins.relations import MonadicRelation
 from cpsskins.relations.interfaces import IRelationStorage, IRelationTool
 from cpsskins.relations.storage import RelationStorage
-from cpsskins.setup.interfaces import IResourceManager
+from cpsskins.setup.interfaces import IResourceManager, IResource
 from cpsskins.setup.settings import Settings, ISettings
 from cpsskins.setup.storage import ISnapshotStorage, SnapshotStorage
 
@@ -128,20 +128,15 @@
         """
 
     def removeFormats(object):
-        """Remove the display of an element
-        """
+        """Remove the display of an element"""
 
-    def getPerspectiveByName(name):
-        """Return a perspective by name
-        """
+    def listPerspectives():
+        """Return the list of perspectives."""
 
     def addPerspective(perspective, id):
         """Add a perspective to the storage
         """
 
-    def listPerspectives():
-        """ """
-
 class ThemeManagementFolder(BTreeContainer, PersistentComponents):
     """A theme management utility that can contain multiple .
     themes
@@ -301,14 +296,16 @@
         relations.add(MonadicRelation(isDefault, object))
 
     def getDefaultTheme(self):
-        """ """
+        """Get the default theme.
+        """
         for theme in self.getThemes():
             if theme.isDefault():
                 return theme
         return None
 
     def getDefaultPage(self):
-        """ """
+        """Get the default page.
+        """
         theme = self.getDefaultTheme()
         for page in theme.getPages():
             if page.isDefault():
@@ -356,18 +353,15 @@
     ###################################################################
 
     def listPerspectives(self):
-        return getUtility(IResourceManager).list(type=IPerspective,
-                                                 context=self)
-
-    def getPerspectiveByName(self, name):
-        """Return a perspective by name."""
-        return getUtility(IResourceManager).lookup(name=name, context=self)
+        resources = getUtility(IResourceManager)
+        return [IResource(r).getResource() for r in
+                resources.list(type=IPerspective, context=self)]
 
     def addPerspective(self, name, title):
         """Add a perspective to the perspective storage.
         """
-        return
         perspective = Perspective(name=name, title=title)
-        mgr = getUtility(IResourceManager)
-        mgr.register(title=title, resource=perspective, context=self)
+        resources = getUtility(IResourceManager)
+        resources.register(name=name, title=title, resource=perspective,
+                           context=self)
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to