web/views/editforms.py
branchtls-sprint
changeset 1183 62afd820d3ae
parent 1179 70825477c6ce
child 1234 4d5ff6a3d539
--- a/web/views/editforms.py	Fri Mar 27 17:08:27 2009 +0100
+++ b/web/views/editforms.py	Fri Mar 27 17:09:43 2009 +0100
@@ -11,6 +11,7 @@
 
 from simplejson import dumps
 
+from logilab.common.decorators import iclassmethod
 from logilab.mtconverter import html_escape
 
 from cubicweb import typed_eid
@@ -292,7 +293,20 @@
                 continue
             result.append((rschema.display_name(entity.req, role), rschema, role))
         return sorted(result)
-                        
+    
+    @iclassmethod
+    def field_by_name(cls_or_self, name, role='subject', eclass=None):
+        try:
+            return super(AutomaticEntityForm, cls_or_self, name, role)
+        except Exception: # XXX should raise more explicit exception
+            if eclass is None:
+                raise
+            field = guess_field(eclass, cls_or_self.schema.rschema(name), role,
+                                eidparam=True)
+            if field is None:
+                raise
+            raise
+            
     
     def __init__(self, *args, **kwargs):
         super(AutomaticEntityForm, self).__init__(*args, **kwargs)