def getRoot(self):
depth = 0
if not self.root:
p = self
while p.getParent() != None and depth < self._maxResourceDepth:
if p is p.getParent():
self.logger.error("Loop in resource parent link. "
"Parent link points back to this resource.")
return None
p = p.getParent()
depth += 1
if isinstance(p, RootResource):
return p
elif depth >= self._maxResourceDepth:
self.logger.error("Possible loop in resource parent links, aborting search")
return None
else:
return None
return self.root
评论列表
文章目录