merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 19 Nov 2009 18:02:19 +0100
branchstable
changeset 3883 b3b3bebdb406
parent 3882 addc715f4fcd (diff)
parent 3880 88fc53eb5b5f (current diff)
child 3885 32634970a36c
merge
--- a/server/schemahooks.py	Thu Nov 19 17:06:46 2009 +0100
+++ b/server/schemahooks.py	Thu Nov 19 18:02:19 2009 +0100
@@ -963,7 +963,7 @@
     # don't use getattr(entity, attr), we would get the modified value if any
     for attr in ro_attrs:
         if attr in entity.edited_attributes:
-            orival, newval = entity_oldnewvalue(entity, attr)
+            origval, newval = entity_oldnewvalue(entity, attr)
             if newval != origval:
                 errors[attr] = session._("can't change the %s attribute") % \
                                display_name(session, attr)
--- a/utils.py	Thu Nov 19 17:06:46 2009 +0100
+++ b/utils.py	Thu Nov 19 18:02:19 2009 +0100
@@ -148,6 +148,20 @@
     return dict1
 
 
+# use networkX instead ?
+# http://networkx.lanl.gov/reference/algorithms.traversal.html#module-networkx.algorithms.traversal.astar
+def transitive_closure_of(entity, relname, _seen=None):
+    if _seen is None:
+        _seen = set()
+    _seen.add(entity.eid)
+    yield entity
+    for child in getattr(entity, relname):
+        if child.eid in _seen:
+            continue
+        for subchild in transitive_closure_of(child, relname, _seen):
+            yield subchild
+
+
 class SizeConstrainedList(list):
     """simple list that makes sure the list does not get bigger
     than a given size.