[forms] catching KeyError closes #961831: migration failure when defining form fields stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 04 Oct 2010 19:05:51 +0200
branchstable
changeset 6392 faee4c380e50
parent 6386 af296184efd6
child 6393 7372100062e8
[forms] catching KeyError closes #961831: migration failure when defining form fields
web/views/autoform.py
--- a/web/views/autoform.py	Mon Oct 04 15:55:55 2010 +0200
+++ b/web/views/autoform.py	Mon Oct 04 19:05:51 2010 +0200
@@ -951,10 +951,11 @@
     global etype_relation_field
 
     def etype_relation_field(etype, rtype, role='subject'):
-        eschema = vreg.schema.eschema(etype)
         try:
+            eschema = vreg.schema.eschema(etype)
             return AutomaticEntityForm.field_by_name(rtype, role, eschema)
-        except f.FieldNotFound:
+        except (KeyError, f.FieldNotFound):
+            # catch KeyError raised when etype/rtype not found in schema
             AutomaticEntityForm.error('field for %s %s may not be found in schema' % (rtype, role))
             return None