--- a
+++ b/projects/FastData2/trunk/fastdata2/widgetfactory.py
@@ -0,0 +1,58 @@
+from view import widget_for
+from toscawidgets.widgets.grids.widgets import Grid, Cell
+from toscawidgets.api import Widget
+from ormdatahandler import is_sqlobject_obj, is_sqlalchemy_obj, is_sa_column, \
+    is_so_column
+
+is_list_with_data = "isinstance(obj, list) and len(obj)>0"
+[widget_for.when(is_list_with_data)]
+def __widget_for_list(obj, cls, **kw):
+    """
+        >>> w = widget_for(obj=[None,None])
+        >>> o = w.render()
+        >>> 'unknown-0' in o
+        True
+        >>> 'unknown-1' in o
+        True
+        >>> 'unknown-2' in o
+        False
+
+    """
+    widget = widget_for(obj=obj[0], **kw)
+    repetitions = len(obj) + kw.get('extra_repetitions', 0)
+    if isinstance(widget, FormField):
+        return FormFieldRepeater(
+            id=widget.id, widget=widget, repetitions=repetitions
+            )
+    return WidgetRepeater(id=widget.id, widget=widget, repetitions=repetitions)
+
+so_list_index = is_list_with_data + \
+            ' and is_sqlobject_obj(obj[0]) and kw.get("action")=="index"'
+[widget_for.when(so_list_index)]
+def _widget_for_soindex(obj, cls, **kw):
+    cols = []
+    for col in list(obj[0].sqlmeta.columnList):
+        w = widget_for(col, action='index')
+        if w:
+            cols.append(w)
+    return Grid(id=obj[0].__class__.__name__ + '_fdindex', columns=cols)
+    
+sa_list_index = is_list_with_data + \
+                'and is_sqlalchemy_obj(obj[0]) and kw.get("action")=="index"'
+[widget_for.when(sa_list_index)]
+def _widget_for_saindex(obj, cls, **kw):
+    cols = []
+    for col in list(obj[0].c):
+        w = widget_for(col, action='index')
+        if w:
+            cols.append(w)
+    return Grid(id=obj[0].__class__.__name__ + '_fdindex', columns=cols)
+
+[widget_for.when('is_sa_column(obj) or is_so_column(obj) ' \
+                'and kw.get("action")=="index"')]
+def _widget_for_orm_column_defaultindex(obj, cls, **kw):
+    return Cell(id=obj.name)
+    
+
+    
+