autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/) tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 12 May 2009 19:20:23 +0200
branchtls-sprint
changeset 1754 c9c7618a90de
parent 1753 ba01605cdd9a
child 1755 1bd225376013
autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
entity.py
web/uicfg.py
web/views/autoform.py
--- a/entity.py	Tue May 12 18:16:11 2009 +0200
+++ b/entity.py	Tue May 12 19:20:23 2009 +0200
@@ -130,8 +130,8 @@
                         wdgname = 'TextInput'
                     widget = getattr(formwidgets, wdgname)
                     assert hasattr(widget, 'render')
-                    uicfg.autoform_widget.tag_subject_of((etype, rtype, '*'),
-                                                         widget)
+                    uicfg.autoform_field_kwargs.tag_subject_of(
+                        (etype, rtype, '*'), {'widget': widget})
         return super(_metaentity, mcs).__new__(mcs, name, bases, classdict)
 
 
--- a/web/uicfg.py	Tue May 12 18:16:11 2009 +0200
+++ b/web/uicfg.py	Tue May 12 19:20:23 2009 +0200
@@ -217,11 +217,12 @@
 # relations'field class
 autoform_field = RelationTags()
 
-# relations'widget class
-autoform_widget = RelationTags()
-autoform_widget.tag_attribute(('RQLExpression', 'expression'),
-                              formwidgets.TextInput)
-autoform_widget.tag_attribute(('Bookmark', 'path'), formwidgets.TextInput)
+# relations'field explicit kwargs (given to field's __init__)
+autoform_field_kwargs = RelationTags()
+autoform_field_kwargs.tag_attribute(('RQLExpression', 'expression'),
+                                    {'widget': formwidgets.TextInput})
+autoform_field_kwargs.tag_attribute(('Bookmark', 'path'),
+                                    {'widget': formwidgets.TextInput})
 
 
 
--- a/web/views/autoform.py	Tue May 12 18:16:11 2009 +0200
+++ b/web/views/autoform.py	Tue May 12 19:20:23 2009 +0200
@@ -40,7 +40,7 @@
     # don't want them to be reloaded
     rcategories = uicfg.autoform_section
     rfields = uicfg.autoform_field
-    rwidgets = uicfg.autoform_widget
+    rfields_kwargs = uicfg.autoform_field_kwargs
     rinlined = uicfg.autoform_is_inlined
     rpermissions_overrides = uicfg.autoform_permissions_overrides
 
@@ -139,10 +139,10 @@
             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, tschemas[0])
-            if widget:
+            kwargs = cls_or_self.rfields_kwargs.etype_get(eschema, rschema, role, tschemas[0])
+            if kwargs:
                 field = guess_field(eschema, rschema, role,
-                                    eidparam=True, widget=widget)
+                                    eidparam=True, **kwargs)
             else:
                 field = guess_field(eschema, rschema, role, eidparam=True)
             if field is None: