[form, migration] etype_relation_field should not raise error, it may block migration if used for a non yet existing field stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 12 Aug 2010 10:11:49 +0200
branchstable
changeset 6101 1aff7367a20c
parent 6100 3cd1e6a74830
child 6102 27c47d239739
child 6103 072f23f6bf83
[form, migration] etype_relation_field should not raise error, it may block migration if used for a non yet existing field
web/views/autoform.py
--- a/web/views/autoform.py	Wed Aug 11 18:11:32 2010 +0200
+++ b/web/views/autoform.py	Thu Aug 12 10:11:49 2010 +0200
@@ -952,6 +952,10 @@
 
     def etype_relation_field(etype, rtype, role='subject'):
         eschema = vreg.schema.eschema(etype)
-        return AutomaticEntityForm.field_by_name(rtype, role, eschema)
+        try:
+            return AutomaticEntityForm.field_by_name(rtype, role, eschema)
+        except f.FieldNotFound:
+            AutomaticEntityForm.error('field for %s %s may not be found in schema' % (rtype, role))
+            return None
 
     vreg.register_all(globals().values(), __name__)