Author: jmorliaguet
Date: Sun Nov 27 15:28:52 2005
New Revision: 1943

Modified:
   cpsskins/branches/jmo-perspectives/browser/tree/slot.py
   cpsskins/branches/jmo-perspectives/elements/display.py
   cpsskins/branches/jmo-perspectives/elements/format.py
   cpsskins/branches/jmo-perspectives/elements/portlet.py
   cpsskins/branches/jmo-perspectives/elements/presentation.py
   cpsskins/branches/jmo-perspectives/elements/slot.py
   cpsskins/branches/jmo-perspectives/relations/configure.zcml
   cpsskins/branches/jmo-perspectives/thememanager.py
Log:

- added an indirection to access the relation tool

  using an adapter: IRelation(context)



Modified: cpsskins/branches/jmo-perspectives/browser/tree/slot.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/tree/slot.py     (original)
+++ cpsskins/branches/jmo-perspectives/browser/tree/slot.py     Sun Nov 27 
15:28:52 2005
@@ -28,9 +28,8 @@
 from cpsskins.elements.interfaces import IPortlet, IDisplayable
 from cpsskins.ontology import hasPortlet, hasPortletFromPerspective
 from cpsskins.relations import DyadicRelation, TriadicRelation
-from cpsskins.relations.tool import RelationTool
 from cpsskins.portlets.storage import IPortletStorage
-from cpsskins.relations.interfaces import IRelationStorage
+from cpsskins.relations.interfaces import IRelationStorage, IRelationTool
 from cpsskins.browser.tree.interfaces import (
     INodeAdding, INodeRemoving, INodeOrdering, INodeMoving, INodeDuplicating
     )
@@ -98,7 +97,7 @@
         # the element is not physically moved but slot -> portlet relations
         # need to be updated.
 
-        reltool = RelationTool(content)
+        reltool = IRelationTool(content)
 
         # TODO: let compound predicates support predicates of different arities
         old_relations = reltool.search(
@@ -159,7 +158,7 @@
 
         portlets = getUtility(IPortletStorage, context=container)
 
-        reltool = RelationTool(container)
+        reltool = IRelationTool(container)
         if perspective is None:
             ids = reltool.search(
                 predicate=hasPortlet,
@@ -226,7 +225,7 @@
 
         duplicated = portlets.duplicate(content)
 
-        reltool = RelationTool(content)
+        reltool = IRelationTool(content)
 
         # Manage relations
         relations = reltool.search(

Modified: cpsskins/branches/jmo-perspectives/elements/display.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/display.py      (original)
+++ cpsskins/branches/jmo-perspectives/elements/display.py      Sun Nov 27 
15:28:52 2005
@@ -30,7 +30,7 @@
 from cpsskins.elements.interfaces import IDisplayable, IDisplay, IDisplayType
 from cpsskins.perspectives.interfaces import IPerspective
 from cpsskins.relations import DyadicRelation, TriadicRelation
-from cpsskins.relations.tool import RelationTool
+from cpsskins.relations.interfaces import IRelationTool
 from cpsskins.ontology import hasDisplay, hasDisplayFromPerspective
 from cpsskins.engines.default.displays.storage import IDisplayStorage
 
@@ -99,7 +99,7 @@
 
         """
         object = self.context
-        reltool = RelationTool(object)
+        reltool = IRelationTool(object)
 
         # if a perspective is specified get the display from that perspective
         if perspective is not None:
@@ -180,7 +180,7 @@
                 third=perspective,
                 )
 
-        reltool = RelationTool(context)
+        reltool = IRelationTool(context)
         reltool.add(relation)
         return display
 
@@ -192,7 +192,7 @@
         display = IDisplayable(context).getDisplay(perspective)
 
         # Remove the relation
-        reltool = RelationTool(context)
+        reltool = IRelationTool(context)
         relations = reltool.search(
             first=context,
             second=display,

Modified: cpsskins/branches/jmo-perspectives/elements/format.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/format.py       (original)
+++ cpsskins/branches/jmo-perspectives/elements/format.py       Sun Nov 27 
15:28:52 2005
@@ -29,7 +29,7 @@
 from cpsskins.engines.default.formats.interfaces import IFormatStorage
 from cpsskins.ontology import hasFormat
 from cpsskins.relations import DyadicRelation
-from cpsskins.relations.tool import RelationTool
+from cpsskins.relations.interfaces import IRelationTool
 
 class Format(Element):
 
@@ -45,7 +45,7 @@
         """Return the list of display elements associated to this
         format.
         """
-        reltool = RelationTool(self)
+        reltool = IRelationTool(self)
         return reltool.getFirsts(second=self, predicate=hasFormat)
 
     formatname = property(_getFormatName)
@@ -109,7 +109,7 @@
 
     def getFormats(self, name=u''):
         context = self.context
-        reltool = RelationTool(context)
+        reltool = IRelationTool(context)
         format = queryUtility(configuration.IFormat, name)
         predicate = format and format.predicate or hasFormat
         return reltool.getSeconds(first=context, predicate=predicate)
@@ -139,7 +139,7 @@
 
         """
         context = self.context
-        reltool = RelationTool(context)
+        reltool = IRelationTool(context)
 
         predicate = getUtility(configuration.IFormat,
                                format.formatname).predicate

Modified: cpsskins/branches/jmo-perspectives/elements/portlet.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/portlet.py      (original)
+++ cpsskins/branches/jmo-perspectives/elements/portlet.py      Sun Nov 27 
15:28:52 2005
@@ -28,7 +28,7 @@
 from cpsskins.elements.interfaces import IPortlet, ISlot, IDisplayable
 from cpsskins.ontology import hasPortlet, hasPortletFromPerspective
 from cpsskins.relations import DyadicRelation, TriadicRelation
-from cpsskins.relations.tool import RelationTool
+from cpsskins.relations.interfaces import IRelationTool
 
 class Portlet(Persistent, Contained):
     """Base class for portlets."""
@@ -65,7 +65,7 @@
             portlet.__parent__ = target
 
             # update the slot -> portlet relation
-            reltool = RelationTool(portlet)
+            reltool = IRelationTool(portlet)
 
             parents = []
             # if the portlet was set from a given perspective retrieve the

Modified: cpsskins/branches/jmo-perspectives/elements/presentation.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/presentation.py (original)
+++ cpsskins/branches/jmo-perspectives/elements/presentation.py Sun Nov 27 
15:28:52 2005
@@ -25,7 +25,7 @@
 from cpsskins.elements.interfaces import (
     IType, IDisplayable, IFormattable, IPresentable)
 from cpsskins.ontology import hasFormat, hasDisplay, hasDisplayFromPerspective
-from cpsskins.relations.tool import RelationTool
+from cpsskins.relations.interfaces import IRelationTool
 from cpsskins.utils import getThemeManager
 
 class Presentable(object):
@@ -76,7 +76,7 @@
             raise ValueError("Must specify a destination perspective")
 
         context = self.context
-        reltool = RelationTool(context)
+        reltool = IRelationTool(context)
 
         displayable = IDisplayable(context)
         default_display = displayable.getDisplay()
@@ -103,7 +103,7 @@
             raise ValueError("Must specify a perspective.")
 
         context = self.context
-        reltool = RelationTool(context)
+        reltool = IRelationTool(context)
 
         displayable = IDisplayable(context)
         display = displayable.getDisplay(perspective)
@@ -125,7 +125,7 @@
             raise ValueError("Must specify a perspective.")
 
         context = self.context
-        reltool = RelationTool(context)
+        reltool = IRelationTool(context)
 
         display = IDisplayable(context).getDisplay(perspective)
         default_display = IDisplayable(context).getDisplay()
@@ -139,7 +139,7 @@
         associated to the element in various perspectives.
         """
         object = self.context
-        reltool = RelationTool(object)
+        reltool = IRelationTool(object)
 
         tmutil = getThemeManager()
         presentations = {}

Modified: cpsskins/branches/jmo-perspectives/elements/slot.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/slot.py (original)
+++ cpsskins/branches/jmo-perspectives/elements/slot.py Sun Nov 27 15:28:52 2005
@@ -23,8 +23,7 @@
 from cpsskins.elements import InnerNode
 from cpsskins.elements.interfaces import ISlot, INode, INodeTraverser
 from cpsskins.ontology import hasPortlet, hasPortletFromPerspective
-from cpsskins.relations.tool import RelationTool
-from cpsskins.relations.interfaces import IRelatable
+from cpsskins.relations.interfaces import IRelatable, IRelationTool
 from cpsskins.portlets.storage import IPortletStorage
 
 class Slot(InnerNode):
@@ -101,7 +100,7 @@
            Override this method if the element is a virtual container.
         """
         node = self.node
-        reltool = RelationTool(node)
+        reltool = IRelationTool(node)
 
         if perspective is None:
             portlets = reltool.getSeconds(

Modified: cpsskins/branches/jmo-perspectives/relations/configure.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/relations/configure.zcml (original)
+++ cpsskins/branches/jmo-perspectives/relations/configure.zcml Sun Nov 27 
15:28:52 2005
@@ -71,4 +71,12 @@
       interface="cpsskins.relations.interfaces.IRelationStorage"
   />
 
+  <!-- Relation tool -->
+
+  <adapter
+      for="*"
+      provides="cpsskins.relations.interfaces.IRelationTool"
+      factory="cpsskins.relations.tool.RelationTool"
+  />
+
 </configure>

Modified: cpsskins/branches/jmo-perspectives/thememanager.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/thememanager.py  (original)
+++ cpsskins/branches/jmo-perspectives/thememanager.py  Sun Nov 27 15:28:52 2005
@@ -39,9 +39,8 @@
 from cpsskins.portlets.interfaces import IPortletStorage
 from cpsskins.portlets.storage import PortletStorage
 from cpsskins.relations import MonadicRelation
-from cpsskins.relations.interfaces import IRelationStorage
+from cpsskins.relations.interfaces import IRelationStorage, IRelationTool
 from cpsskins.relations.storage import RelationStorage
-from cpsskins.relations.tool import RelationTool
 from cpsskins.setup.interfaces import IResourceManager, ISettings
 from cpsskins.setup.settings import Settings
 
@@ -172,7 +171,7 @@
     def removeDisplays(self, object):
         """Remove the displays of a given element
         """
-        reltool = RelationTool(object)
+        reltool = IRelationTool(object)
         display_relations = reltool.search(first=object, predicate=hasDisplay)
 
         # Physically remove the displays
@@ -197,7 +196,7 @@
             del container[zapi.name(format)]
 
         # Remove the relation
-        reltool = RelationTool(object)
+        reltool = IRelationTool(object)
         relations = reltool.search(first=object, predicate=hasFormat)
         reltool.remove(relations)
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to