take a sample target type instead of '*' else we may miss some expected values (we may still miss some...) tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 12 May 2009 16:27:23 +0200
branchtls-sprint
changeset 1743 591cff8f0701
parent 1742 25a765e756c4
child 1744 056ed8fca8d3
take a sample target type instead of '*' else we may miss some expected values (we may still miss some...)
web/views/autoform.py
--- a/web/views/autoform.py	Tue May 12 16:24:27 2009 +0200
+++ b/web/views/autoform.py	Tue May 12 16:27:23 2009 +0200
@@ -145,10 +145,12 @@
             if eschema is None or not name in cls_or_self.schema:
                 raise
             rschema = cls_or_self.schema.rschema(name)
-            fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role)
+            # XXX use a sample target type. Document this.
+            tschemas = rschema.targets(eschema, role)
+            fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role, tschemas[0])
             if fieldcls:
                 return fieldcls(name=name, role=role, eidparam=True)
-            widget = cls_or_self.rwidgets.etype_get(eschema, rschema, role)
+            widget = cls_or_self.rwidgets.etype_get(eschema, rschema, role, tschemas[0])
             if widget:
                 field = guess_field(eschema, rschema, role,
                                     eidparam=True, widget=widget)