[prev in list] [next in list] [prev in thread] [next in thread] 

List:       luci-commits
Subject:    [Luci-commits] [luci] Restore AWOL searchObjectTree method
From:       rmccabe () fedoraproject ! org (Ryan McCabe)
Date:       2010-11-17 15:46:07
Message-ID: 20101117154607.7BEBD120350 () lists ! fedorahosted ! org
[Download RAW message or body]

commit 02863d81dd11b9baeeabfa1d0132d56c3ab3d11c
Author: Ryan McCabe <rmccabe at redhat.com>
Date:   Wed Nov 17 10:45:49 2010 -0500

    Restore AWOL searchObjectTree method

 luci/lib/ClusterConf/ModelBuilder.py |    6 ++++++
 luci/lib/ClusterConf/TagObject.py    |    9 +++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/luci/lib/ClusterConf/ModelBuilder.py b/luci/lib/ClusterConf/ModelBuilder.py
index ad14308..484f7b7 100644
--- a/luci/lib/ClusterConf/ModelBuilder.py
+++ b/luci/lib/ClusterConf/ModelBuilder.py
@@ -1023,3 +1023,9 @@ class ModelBuilder:
                 break
         if found_one is True:
           break
+
+  def searchObjectTree(self, tagtype):
+    objlist = list()
+    self.object_tree.searchTree(objlist, tagtype)
+
+    return objlist
diff --git a/luci/lib/ClusterConf/TagObject.py b/luci/lib/ClusterConf/TagObject.py
index 2d24cc6..9d72a7e 100644
--- a/luci/lib/ClusterConf/TagObject.py
+++ b/luci/lib/ClusterConf/TagObject.py
@@ -142,6 +142,15 @@ class TagObject(object):
   def isRefObject(self):
     return False
 
+  def searchTree(self, objlist, tagtype):
+    if self.TAG_NAME == tagtype:
+      objlist.append(self)
+    if len(self.children) > 0:
+      for child in self.children:
+        if child is None:
+          continue
+        child.searchTree(objlist, tagtype)
+
   def replaceChild(self, oldchild, newchild):
     """Looks up oldchild and replace it with newchild."""
     idx = self.children.index(oldchild)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic