equal
deleted
inserted
replaced
25 from logilab.common.deprecation import deprecated |
25 from logilab.common.deprecation import deprecated |
26 from logilab.common.graph import ordered_nodes |
26 from logilab.common.graph import ordered_nodes |
27 |
27 |
28 from rql.utils import rqlvar_maker |
28 from rql.utils import rqlvar_maker |
29 |
29 |
30 from cubicweb import Binary, ValidationError |
30 from cubicweb import Binary, ValidationError, UnknownEid |
31 from cubicweb.view import EntityAdapter |
31 from cubicweb.view import EntityAdapter |
32 from cubicweb.predicates import is_instance |
32 from cubicweb.predicates import is_instance |
33 from cubicweb.web import (INTERNAL_FIELD_VALUE, RequestError, NothingToEdit, |
33 from cubicweb.web import (INTERNAL_FIELD_VALUE, RequestError, NothingToEdit, |
34 ProcessFormError) |
34 ProcessFormError) |
35 from cubicweb.web.views import basecontrollers, autoform |
35 from cubicweb.web.views import basecontrollers, autoform |
338 |
338 |
339 See for instance test_subject_subentity_removal in |
339 See for instance test_subject_subentity_removal in |
340 web/test/unittest_application.py. |
340 web/test/unittest_application.py. |
341 """ |
341 """ |
342 rschema = self._cw.vreg.schema.rschema(field.name) |
342 rschema = self._cw.vreg.schema.rschema(field.name) |
343 new_value_etypes = set(self._cw.entity_from_eid(eid).cw_etype |
343 new_value_etypes = set() |
344 for eid in new_values) |
344 # the user could have included nonexisting eids in the POST; don't crash. |
|
345 for eid in new_values: |
|
346 try: |
|
347 new_value_etypes.add(self._cw.entity_from_eid(eid).cw_etype) |
|
348 except UnknownEid: |
|
349 continue |
345 for unlinked_eid in removed_values: |
350 for unlinked_eid in removed_values: |
346 unlinked_entity = self._cw.entity_from_eid(unlinked_eid) |
351 unlinked_entity = self._cw.entity_from_eid(unlinked_eid) |
347 rdef = rschema.role_rdef(form.edited_entity.cw_etype, |
352 rdef = rschema.role_rdef(form.edited_entity.cw_etype, |
348 unlinked_entity.cw_etype, |
353 unlinked_entity.cw_etype, |
349 field.role) |
354 field.role) |