[Commits] (vajda) improved cloud trace feature

commits at osafoundation.org commits at osafoundation.org
Thu Apr 7 10:13:31 PDT 2005


Commit by: vajda
Modified files:
chandler/repository/schema/Cloud.py 1.26 1.27
chandler/application/tests/TestClouds.py 1.7 1.8

Log message:
improved cloud trace feature

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Cloud.py.diff?r1=text&tr1=1.26&r2=text&tr2=1.27
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/TestClouds.py.diff?r1=text&tr1=1.7&r2=text&tr2=1.8

Index: chandler/repository/schema/Cloud.py
diff -u chandler/repository/schema/Cloud.py:1.26 chandler/repository/schema/Cloud.py:1.27
--- chandler/repository/schema/Cloud.py:1.26	Tue Apr  5 11:15:12 2005
+++ chandler/repository/schema/Cloud.py	Thu Apr  7 10:13:30 2005
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.26 $"
-__date__      = "$Date: 2005/04/05 18:15:12 $"
+__revision__  = "$Revision: 1.27 $"
+__date__      = "$Date: 2005/04/07 17:13:30 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -324,7 +324,6 @@
         @type cloudAlias: a string
         """
 
-
         if not item.isItemOf(self.kind):
             raise TypeError, '%s (Kind: %s) is not of a kind this cloud (%s) understands' %(item.itsPath, item._kind.itsPath, self.itsPath)
 
@@ -332,17 +331,20 @@
             for other in endpoint.iterValues(item):
                 yield other
 
-    def traceItem(self, item, trace):
+    def traceItem(self, item, trace, indent=0, done=None):
 
-        found = True
-        while found:
-            found = False
-            for (other, endpoint), others in trace.iteritems():
-                if item in others:
-                    yield (item, other, '.'.join(endpoint.attribute))
-                    item = other
-                    found = True
-                    break
+        if done is None:
+            done = set()
+        elif item in done:
+            return
+
+        done.add(item)
+        for (other, endpoint), others in trace.iteritems():
+            if item in others:
+                yield (item, other, '.'.join(endpoint.attribute),
+                       endpoint.includePolicy, indent)
+                for tuple in self.traceItem(other, trace, indent + 1, done):
+                    yield tuple
 
 
 class Endpoint(Item):

Index: chandler/application/tests/TestClouds.py
diff -u chandler/application/tests/TestClouds.py:1.7 chandler/application/tests/TestClouds.py:1.8
--- chandler/application/tests/TestClouds.py:1.7	Tue Apr  5 11:15:11 2005
+++ chandler/application/tests/TestClouds.py	Thu Apr  7 10:13:30 2005
@@ -1,8 +1,8 @@
 """
 Test of Cloud copy
 """
-__revision__  = "$Revision: 1.7 $"
-__date__      = "$Date: 2005/04/05 18:15:11 $"
+__revision__  = "$Revision: 1.8 $"
+__date__      = "$Date: 2005/04/07 17:13:30 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -41,10 +41,12 @@
 
         sB = self.rep.findPath("//parcels/clouds/data/sprocketB")
         cloud = widgetA.itsKind.getClouds('default')[0]
-        for item, other, attribute in cloud.traceItem(sB, trace):
-            print "%s was added by following '%s' on %s" %(item._repr_(),
-                                                           attribute,
-                                                           other._repr_())
+        for item, other, attribute, policy, indent in cloud.traceItem(sB, trace):
+            print "%s%s was added by following '%s' %s on %s" %('  ' * indent,
+                                                                item._repr_(),
+                                                                attribute,
+                                                                policy,
+                                                                other._repr_())
 
         for item in items:
             path = str(item.itsPath)



More information about the Commits mailing list