[web] Clear "pending_others" session key after all relations got processed
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 16 Aug 2016 16:00:32 +0200
changeset 11741 8f264d98d6fd
parent 11740 dabbb2a4a493
child 11742 def9b3757945
[web] Clear "pending_others" session key after all relations got processed The RelationField appends data to "pending_others" key while processing its posted information, but this key may already have been removed by the edit controller. So remove the key from session data only when all "others" relations have been processed using a while loop. A test case would be nice, but I could not build one easily unfortunately. Closes #4354551.
cubicweb/web/views/editcontroller.py
--- a/cubicweb/web/views/editcontroller.py	Wed Sep 28 11:06:28 2016 +0200
+++ b/cubicweb/web/views/editcontroller.py	Tue Aug 16 16:00:32 2016 +0200
@@ -209,8 +209,10 @@
         pending_inlined = req.data.pop('pending_inlined')
         assert not pending_inlined, pending_inlined
         # handle all other remaining relations now
-        for form_, field in req.data.pop('pending_others'):
+        while req.data['pending_others']:
+            form_, field = req.data['pending_others'].pop()
             self.handle_formfield(form_, field)
+        del req.data['pending_others']
         # then execute rql to set all relations
         for querydef in self.relations_rql:
             self._cw.execute(*querydef)