[Commits] (vajda) added cloud trace feature

commits at osafoundation.org commits at osafoundation.org
Mon Apr 4 19:23:41 PDT 2005


Commit by: vajda
Modified files:
chandler/application/tests/TestClouds.py 1.5 1.6
chandler/repository/item/Item.py 1.204 1.205
chandler/repository/schema/Cloud.py 1.24 1.25

Log message:
added cloud trace feature

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/TestClouds.py.diff?r1=text&tr1=1.5&r2=text&tr2=1.6
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Item.py.diff?r1=text&tr1=1.204&r2=text&tr2=1.205
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Cloud.py.diff?r1=text&tr1=1.24&r2=text&tr2=1.25

Index: chandler/application/tests/TestClouds.py
diff -u chandler/application/tests/TestClouds.py:1.5 chandler/application/tests/TestClouds.py:1.6
--- chandler/application/tests/TestClouds.py:1.5	Tue Nov  9 15:10:47 2004
+++ chandler/application/tests/TestClouds.py	Mon Apr  4 19:23:39 2005
@@ -1,8 +1,8 @@
 """
 Test of Cloud copy
 """
-__revision__  = "$Revision: 1.5 $"
-__date__      = "$Date: 2004/11/09 23:10:47 $"
+__revision__  = "$Revision: 1.6 $"
+__date__      = "$Date: 2005/04/05 02:23:39 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -27,7 +27,8 @@
 
         # This is how you determine which items would get copied if you
         # were doing a cloud copy:
-        items = widgetA.getItemCloud('default')
+        trace={}
+        items = widgetA.getItemCloud('default', trace=trace)
 
         expectedItems = [
             "//parcels/clouds/data/widgetA",
@@ -38,6 +39,11 @@
             "//parcels/clouds/data/sprocketC",
         ]
 
+        sB = self.rep.findPath("//parcels/clouds/data/sprocketB")
+        for (item, endpoint), others in trace.iteritems():
+            if sB in others:
+                print "%s was added by following '%s' on %s" %(sB, '.'.join(endpoint.attribute), item._repr_())
+
         for item in items:
             path = str(item.itsPath)
             self.assert_(path in expectedItems)

Index: chandler/repository/item/Item.py
diff -u chandler/repository/item/Item.py:1.204 chandler/repository/item/Item.py:1.205
--- chandler/repository/item/Item.py:1.204	Mon Apr  4 15:13:19 2005
+++ chandler/repository/item/Item.py	Mon Apr  4 19:23:39 2005
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.204 $"
-__date__      = "$Date: 2005/04/04 22:13:19 $"
+__revision__  = "$Revision: 1.205 $"
+__date__      = "$Date: 2005/04/05 02:23:39 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -1254,7 +1254,7 @@
 
         collectItems(self)
 
-    def getItemCloud(self, cloudAlias, items=None):
+    def getItemCloud(self, cloudAlias, items=None, trace=None):
         """
         Get the items in a cloud by using this item as entrypoint.
 
@@ -1270,7 +1270,7 @@
         if items is None:
             items = {}
         for cloud in self._kind.getClouds(cloudAlias):
-            cloud.getItems(self, cloudAlias, items)
+            cloud.getItems(self, cloudAlias, items, None, trace)
 
         return items.values()
 

Index: chandler/repository/schema/Cloud.py
diff -u chandler/repository/schema/Cloud.py:1.24 chandler/repository/schema/Cloud.py:1.25
--- chandler/repository/schema/Cloud.py:1.24	Fri Mar 18 13:41:51 2005
+++ chandler/repository/schema/Cloud.py	Mon Apr  4 19:23:40 2005
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.24 $"
-__date__      = "$Date: 2005/03/18 21:41:51 $"
+__revision__  = "$Revision: 1.25 $"
+__date__      = "$Date: 2005/04/05 02:23:40 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -17,7 +17,8 @@
 
 class Cloud(Item):
 
-    def getItems(self, item, cloudAlias, items=None, references=None):
+    def getItems(self, item, cloudAlias, items=None, references=None,
+                 trace=None):
         """
         Gather all items in the cloud from a given item entrypoint.
 
@@ -83,8 +84,11 @@
         for alias, endpoint, inCloud in self.iterEndpoints(cloudAlias):
             for other in endpoint.iterValues(item):
                 if other is not None and other._uuid not in items:
-                    results.extend(endpoint.getItems(other, cloudAlias,
-                                                     items, references))
+                    _items = endpoint.getItems(other, cloudAlias,
+                                               items, references, trace)
+                    if trace is not None:
+                        trace[(item, endpoint)] = _items
+                    results.extend(_items)
 
         return results
 
@@ -331,7 +335,7 @@
 
 class Endpoint(Item):
 
-    def getItems(self, item, cloudAlias, items, references):
+    def getItems(self, item, cloudAlias, items, references, trace):
 
         policy = self.includePolicy
         results = []
@@ -348,7 +352,7 @@
 
             def getItems(cloud):
                 results.extend(cloud.getItems(item, cloudAlias,
-                                              items, references))
+                                              items, references, trace))
 
             cloud = self.getAttributeValue('cloud', default=None,
                                            _attrDict=self._references)



More information about the Commits mailing list