web/views/autoform.py
branchstable
changeset 6392 faee4c380e50
parent 6101 1aff7367a20c
child 6401 d7f5d873e1b8
equal deleted inserted replaced
6386:af296184efd6 6392:faee4c380e50
   949 
   949 
   950 def registration_callback(vreg):
   950 def registration_callback(vreg):
   951     global etype_relation_field
   951     global etype_relation_field
   952 
   952 
   953     def etype_relation_field(etype, rtype, role='subject'):
   953     def etype_relation_field(etype, rtype, role='subject'):
   954         eschema = vreg.schema.eschema(etype)
       
   955         try:
   954         try:
       
   955             eschema = vreg.schema.eschema(etype)
   956             return AutomaticEntityForm.field_by_name(rtype, role, eschema)
   956             return AutomaticEntityForm.field_by_name(rtype, role, eschema)
   957         except f.FieldNotFound:
   957         except (KeyError, f.FieldNotFound):
       
   958             # catch KeyError raised when etype/rtype not found in schema
   958             AutomaticEntityForm.error('field for %s %s may not be found in schema' % (rtype, role))
   959             AutomaticEntityForm.error('field for %s %s may not be found in schema' % (rtype, role))
   959             return None
   960             return None
   960 
   961 
   961     vreg.register_all(globals().values(), __name__)
   962     vreg.register_all(globals().values(), __name__)