web/views/editcontroller.py
changeset 11114 468b91aabd9d
parent 11066 dcbb64d3a1d9
child 11118 0c645f09d96a
--- a/web/views/editcontroller.py	Wed Feb 03 15:12:32 2016 +0100
+++ b/web/views/editcontroller.py	Tue Feb 16 10:52:38 2016 +0100
@@ -27,7 +27,7 @@
 
 from rql.utils import rqlvar_maker
 
-from cubicweb import Binary, ValidationError
+from cubicweb import Binary, ValidationError, UnknownEid
 from cubicweb.view import EntityAdapter
 from cubicweb.predicates import is_instance
 from cubicweb.web import (INTERNAL_FIELD_VALUE, RequestError, NothingToEdit,
@@ -340,8 +340,13 @@
         web/test/unittest_application.py.
         """
         rschema = self._cw.vreg.schema.rschema(field.name)
-        new_value_etypes = set(self._cw.entity_from_eid(eid).cw_etype
-                               for eid in new_values)
+        new_value_etypes = set()
+        # the user could have included nonexisting eids in the POST; don't crash.
+        for eid in new_values:
+            try:
+                new_value_etypes.add(self._cw.entity_from_eid(eid).cw_etype)
+            except UnknownEid:
+                continue
         for unlinked_eid in removed_values:
             unlinked_entity = self._cw.entity_from_eid(unlinked_eid)
             rdef = rschema.role_rdef(form.edited_entity.cw_etype,