[forms] catching KeyError closes #961831: migration failure when defining form fields

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changesetfaee4c380e50
branchstable
phasepublic
hiddenno
parent revision#af296184efd6 [vreg] fix bad copy and paste introduced in 6347:ef47a2100c66
child revision#7372100062e8 include fcayre's patch #1060507 to get extra rql query parameters from form content in rgx_action
files modified by this revision
web/views/autoform.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1286211951 -7200
# Mon Oct 04 19:05:51 2010 +0200
# Branch stable
# Node ID faee4c380e50d58fbb6430dd5edd50ab6f37856b
# Parent af296184efd6bdc39f7b7ae6eaeeec5830d91360
[forms] catching KeyError closes #961831: migration failure when defining form fields

diff --git a/web/views/autoform.py b/web/views/autoform.py
@@ -949,13 +949,14 @@
1 
2  def registration_callback(vreg):
3      global etype_relation_field
4 
5      def etype_relation_field(etype, rtype, role='subject'):
6 -        eschema = vreg.schema.eschema(etype)
7          try:
8 +            eschema = vreg.schema.eschema(etype)
9              return AutomaticEntityForm.field_by_name(rtype, role, eschema)
10 -        except f.FieldNotFound:
11 +        except (KeyError, f.FieldNotFound):
12 +            # catch KeyError raised when etype/rtype not found in schema
13              AutomaticEntityForm.error('field for %s %s may not be found in schema' % (rtype, role))
14              return None
15 
16      vreg.register_all(globals().values(), __name__)