[debug] when a loop is detected in a tree, log the entity involved in it to ease repair

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changesetb5f15098f282
branchstable
phasepublic
hiddenno
parent revision#9d40ee3d0551 [image js] fix image fit screen function
child revision#a5e22657f6f4 [debug] improve debug messages, #d56fd78006cd [session] cleanup session-time / cleanup-session-time...
files modified by this revision
entities/adapters.py
mixins.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1280138820 -7200
# Mon Jul 26 12:07:00 2010 +0200
# Branch stable
# Node ID b5f15098f282216cb91a5c507c0dc49e074a7eae
# Parent 9d40ee3d0551f4a7dea8c6c17e310dbe2ffe618c
[debug] when a loop is detected in a tree, log the entity involved in it to ease repair

diff --git a/entities/adapters.py b/entities/adapters.py
@@ -292,11 +292,11 @@
1          """iterates over the item's children"""
2          if _done is None:
3              _done = set()
4          for child in self.children():
5              if child.eid in _done:
6 -                self.error('loop in %s tree', child.__regid__.lower())
7 +                self.error('loop in %s tree: %s', child.__regid__.lower(), child)
8                  continue
9              yield child
10              _done.add(child.eid)
11 
12      @implements_adapter_compat('ITree')
@@ -318,11 +318,11 @@
13          path = []
14          adapter = self
15          entity = adapter.entity
16          while entity is not None:
17              if entity.eid in path:
18 -                self.error('loop in %s tree', entity.__regid__.lower())
19 +                self.error('loop in %s tree: %s', entity.__regid__.lower(), entity)
20                  break
21              path.append(entity.eid)
22              try:
23                  # check we are not jumping to another tree
24                  if (adapter.tree_relation != self.tree_relation or
diff --git a/mixins.py b/mixins.py
@@ -69,11 +69,11 @@
25      def iterchildren(self, _done=None):
26          if _done is None:
27              _done = set()
28          for child in self.children():
29              if child.eid in _done:
30 -                self.error('loop in %s tree', self.__regid__.lower())
31 +                self.error('loop in %s tree: %s', self.__regid__.lower(), child)
32                  continue
33              yield child
34              _done.add(child.eid)
35 
36      def prefixiter(self, _done=None):
@@ -92,11 +92,11 @@
37          """returns the list of eids from the root object to this object"""
38          path = []
39          parent = self
40          while parent:
41              if parent.eid in path:
42 -                self.error('loop in %s tree', self.__regid__.lower())
43 +                self.error('loop in %s tree: %s', self.__regid__.lower(), parent)
44                  break
45              path.append(parent.eid)
46              try:
47                  # check we are not leaving the tree
48                  if (parent.tree_attribute != self.tree_attribute or