optimization when adding child groups

parent 36298672
...@@ -35,9 +35,12 @@ class Group(object): ...@@ -35,9 +35,12 @@ class Group(object):
if self == group: if self == group:
raise Exception("can't add group to itself") raise Exception("can't add group to itself")
self.child_groups.append(group)
group.depth = max([self.depth+1, group.depth]) # don't add if it's already there
group.parent_groups.append(self) if not group in self.child_groups:
self.child_groups.append(group)
group.depth = max([self.depth+1, group.depth])
group.parent_groups.append(self)
def add_host(self, host): def add_host(self, host):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment