web/views/tableview.py
branchstable
changeset 5312 d2dbba898a96
parent 4618 412a9f1f5fd0
child 5328 c51e8f62652a
child 5377 84d14ddfae13
--- a/web/views/tableview.py	Fri Apr 16 14:39:42 2010 +0200
+++ b/web/views/tableview.py	Fri Apr 16 16:40:25 2010 +0200
@@ -23,6 +23,11 @@
 from cubicweb.web.facet import prepare_facets_rqlst, filter_hiddens
 
 class TableView(AnyRsetView):
+    """The table view accepts any non-empty rset. It uses
+    introspection on the result set to compute column names and the
+    proper way to display the cells.
+    It is however highly configurable and accepts a wealth of options.
+    """
     __regid__ = 'table'
     title = _('table')
     finalview = 'final'
@@ -50,29 +55,30 @@
 
     def _generate_form(self, divid, baserql, fwidgets, hidden=True, vidargs={}):
         """display a form to filter table's content. This should only
-        occurs when a context eid is given
+        occur when a context eid is given
         """
+        w = self.w
         self._cw.add_css('cubicweb.facets.css')
         self._cw.add_js( ('cubicweb.ajax.js', 'cubicweb.facets.js'))
         # drop False / None values from vidargs
         vidargs = dict((k, v) for k, v in vidargs.iteritems() if v)
-        self.w(u'<form method="post" cubicweb:facetargs="%s" action="">' %
-               xml_escape(dumps([divid, 'table', False, vidargs])))
-        self.w(u'<fieldset id="%sForm" class="%s">' % (divid, hidden and 'hidden' or ''))
-        self.w(u'<input type="hidden" name="divid" value="%s" />' % divid)
-        self.w(u'<input type="hidden" name="fromformfilter" value="1" />')
-        filter_hiddens(self.w, facets=','.join(wdg.facet.__regid__ for wdg in fwidgets),
+        w(u'<form method="post" cubicweb:facetargs="%s" action="">' %
+          xml_escape(dumps([divid, 'table', False, vidargs])))
+        w(u'<fieldset id="%sForm" class="%s">' % (divid, hidden and 'hidden' or ''))
+        w(u'<input type="hidden" name="divid" value="%s" />' % divid)
+        w(u'<input type="hidden" name="fromformfilter" value="1" />')
+        filter_hiddens(w, facets=','.join(wdg.facet.__regid__ for wdg in fwidgets),
                        baserql=baserql)
-        self.w(u'<table class="filter">\n')
-        self.w(u'<tr>\n')
+        w(u'<table class="filter">\n')
+        w(u'<tr>\n')
         for wdg in fwidgets:
-            self.w(u'<td>')
-            wdg.render(w=self.w)
-            self.w(u'</td>\n')
-        self.w(u'</tr>\n')
-        self.w(u'</table>\n')
-        self.w(u'</fieldset>\n')
-        self.w(u'</form>\n')
+            w(u'<td>')
+            wdg.render(w=w)
+            w(u'</td>\n')
+        w(u'</tr>\n')
+        w(u'</table>\n')
+        w(u'</fieldset>\n')
+        w(u'</form>\n')
 
     def main_var_index(self):
         """returns the index of the first non-attribute variable among the RQL
@@ -98,7 +104,7 @@
     def call(self, title=None, subvid=None, displayfilter=None, headers=None,
              displaycols=None, displayactions=None, actions=(), divid=None,
              cellvids=None, cellattrs=None, mainindex=None):
-        """Dumps a table displaying a composite query
+        """Produces a table displaying a composite query
 
         :param title: title added before table
         :param subvid: cell view