[Commits] (morgen) Query items no longer allow you to find their children by iterating on them

commits at osafoundation.org commits at osafoundation.org
Mon Mar 22 13:52:27 PST 2004


Commit by: morgen
Modified files:
osaf/chandler/Chandler/repository/parcel/Util.py 1.7 1.8

Log message:
Query items no longer allow you to find their children by iterating on them
as in "for child in item:", so instead I am using item.iterChildren()
Also, if the path passed into PrintItem() doesn't exist in the repository
an error message is displayed and the function returns.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/parcel/Util.py.diff?r1=text&tr1=1.7&r2=text&tr2=1.8

Index: osaf/chandler/Chandler/repository/parcel/Util.py
diff -u osaf/chandler/Chandler/repository/parcel/Util.py:1.7 osaf/chandler/Chandler/repository/parcel/Util.py:1.8
--- osaf/chandler/Chandler/repository/parcel/Util.py:1.7	Mon Mar 22 10:53:07 2004
+++ osaf/chandler/Chandler/repository/parcel/Util.py	Mon Mar 22 13:51:56 2004
@@ -2,8 +2,8 @@
 Utility functions for displaying repository contents
 """
 
-__revision__  = "$Revision: 1.7 $"
-__date__      = "$Date: 2004/03/22 18:53:07 $"
+__revision__  = "$Revision: 1.8 $"
+__date__      = "$Date: 2004/03/22 21:51:56 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -19,11 +19,19 @@
     for i in range(level):
         print " ",
     item = rep.find(uri)
-    print "%s (Kind: %s)" % (uri, item.kind.getItemPath() )
+    if not item:
+        print "Error: %s was not found" % uri
+        return
+
+    if item.hasAttributeValue("kind"):
+        print "%s (Kind: %s)" % (uri, item.kind.getItemPath() )
+    else:
+        print "%s" % (uri)
 
     # For Kinds, display their attributes (except for the internal ones
     # like notFoundAttributes:
-    if "//Schema/Core/Kind" == str(item.kind.getItemPath()):
+    if item.hasAttributeValue("kind") and \
+     "//Schema/Core/Kind" == str(item.kind.getItemPath()):
         for i in range(level+2):
             print " ",
         print "attributes:"
@@ -103,7 +111,7 @@
 
     print
 
-    for child in item:
-        childuri = child.getItemPath()
-        PrintItem(childuri, rep, level+1)
-
+    if item.hasChildren():
+        for child in item.iterChildren():
+            childuri = child.getItemPath()
+            PrintItem(childuri, rep, level+1)



More information about the Commits mailing list