merge stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 19 Nov 2009 19:50:36 +0100
branchstable
changeset 3885 32634970a36c
parent 3884 b0ff58d929a4 (current diff)
parent 3883 b3b3bebdb406 (diff)
child 3886 6389e5d6edcb
child 3888 6f145783409d
merge
--- a/utils.py	Thu Nov 19 19:48:41 2009 +0100
+++ b/utils.py	Thu Nov 19 19:50:36 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.
--- a/web/views/editforms.py	Thu Nov 19 19:48:41 2009 +0100
+++ b/web/views/editforms.py	Thu Nov 19 19:50:36 2009 +0100
@@ -436,6 +436,7 @@
             form = self.vreg['forms'].select('edition', self.req,
                                              rset=self.rset, row=row,
                                              attrcategories=('primary',),
+                                             copy_nav_params=False,
                                              mainform=False)
             # XXX rely on the EntityCompositeFormRenderer to put the eid input
             form.remove_field(form.field_by_name('eid'))
@@ -452,7 +453,8 @@
         should be the eid
         """
         #self.form_title(entity)
-        form = self.vreg['forms'].select(self.id, self.req, rset=self.rset)
+        form = self.vreg['forms'].select(self.id, self.req, rset=self.rset,
+                                         copy_nav_params=True)
         self.w(form.form_render())
 
 
--- a/web/views/forms.py	Thu Nov 19 19:48:41 2009 +0100
+++ b/web/views/forms.py	Thu Nov 19 19:50:36 2009 +0100
@@ -89,6 +89,7 @@
         if mainform:
             self.form_add_hidden('__errorurl', self.session_key())
             self.form_add_hidden('__domid', self.domid)
+        # XXX why do we need two different variables (mainform and copy_nav_params ?)
         if self.copy_nav_params:
             for param in NAV_FORM_PARAMETERS:
                 if not param in kwargs: