# HG changeset patch # User Sylvain Thénault # Date 1317716146 -7200 # Node ID ac658ab4c7b773651020ba68c3b4a1a2e7866244 # Parent 2ada3052e626a11d27204de4a51d43874b8cce8d [pyviews] new colheaders and cssclass arguments on pyvaltable (closes #1979718) diff -r 2ada3052e626 -r ac658ab4c7b7 web/views/pyviews.py --- a/web/views/pyviews.py Tue Oct 04 10:15:45 2011 +0200 +++ b/web/views/pyviews.py Tue Oct 04 10:15:46 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -24,18 +24,29 @@ class PyValTableView(View): - """display a list of list of values into an html table. + """display a list of list of values into an HTML table. Take care, content is NOT xml-escaped. + + If `headers` is specfied, it is expected to be a list of headers to be + inserted as first row (in ). + + If `colheaders` is True, the first column will be considered as an headers + column an its values will be inserted inside instead of . + + `cssclass` is the CSS class used on the tag, and default to + 'listing' (so that the table will look similar to those generated by the + table view). """ __regid__ = 'pyvaltable' __select__ = match_kwargs('pyvalue') - def call(self, pyvalue, headers=None): + def call(self, pyvalue, headers=None, colheaders=False, + cssclass='listing'): if headers is None: headers = self._cw.form.get('headers') w = self.w - w(u'
\n') + w(u'
\n' % cssclass) if headers: w(u'') w(u'') @@ -46,6 +57,9 @@ w(u'') for row in pyvalue: w(u'') + if colheaders: + w(u'' % row[0]) + row = row[1:] for cell in row: w(u'' % cell) w(u'\n')
%s%s