Make EditController edit_entity method always return an eid stable
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 26 Feb 2014 14:50:13 +0100
branchstable
changeset 9590 048d6de92b63
parent 9589 7e4897901c64
child 9591 5b8bc486d0dc
Make EditController edit_entity method always return an eid In cases the entity was to be created or copied, eid was None hence the method returned None despite the dosctring says the method should always return an eid. Now if the eid variable is None, it is assigned to the newly created entity eid. Closes #3593029.
web/views/editcontroller.py
--- a/web/views/editcontroller.py	Wed Mar 26 11:08:09 2014 +0100
+++ b/web/views/editcontroller.py	Wed Feb 26 14:50:13 2014 +0100
@@ -272,7 +272,7 @@
             errors = dict((f.role_name(), unicode(ex)) for f, ex in self.errors)
             raise ValidationError(valerror_eid(entity.eid), errors)
         if eid is None: # creation or copy
-            entity.eid = self._insert_entity(etype, formparams['eid'], rqlquery)
+            entity.eid = eid = self._insert_entity(etype, formparams['eid'], rqlquery)
         elif rqlquery.edited: # edition of an existant entity
             self._update_entity(eid, rqlquery)
         if is_main_entity: