--- a/pvl/verkko/table.py Sun Feb 10 13:20:29 2013 +0200
+++ b/pvl/verkko/table.py Sun Feb 10 13:29:27 2013 +0200
@@ -81,20 +81,25 @@
return html.td(class_=self.colcss)(input)
- def cell_html (self, item) :
+ def cell_value (self, item) :
+ """
+ Return value for cell.
+ """
+
+ # XXX: this is sometimes broken, figure out how to index by column
+ return getattr(item, self.attr)
+
+ def cell_html (self, item, value) :
"""
Render contents for <td>.
"""
- # XXX: this is sometimes broken, figure out how to index by column
- value = getattr(item, self.attr)
-
if self.rowhtml :
return self.rowhtml(item)
else :
return value
- def cell_css (self, item, hilight=None) :
+ def cell_css (self, item, value=None, hilight=None) :
"""
Return CSS classes for <td>.
"""
@@ -112,7 +117,7 @@
if hilight :
yield 'hilight'
- def cell_title (self, item) :
+ def cell_title (self, item, value=None) :
"""
Return title= for <td>
"""
@@ -127,8 +132,7 @@
hilight - optionally higlight given { attr: value }'s using CSS.
"""
- # XXX: this is sometimes broken, figure out how to index by column
- value = getattr(item, self.attr)
+ value = self.cell_value(item)
if self.rowfilter and filters is not None :
# filter-link by row-value
@@ -136,8 +140,8 @@
else :
filters = None
- yield table.render_cell(self.cell_html(item),
- css = tuple(self.cell_css(item, hilight=hilight)),
+ yield table.render_cell(self.cell_html(item, value),
+ css = tuple(self.cell_css(item, value, hilight=hilight)),
filters = filters,
title = self.cell_title(item),
)
@@ -370,10 +374,12 @@
yield 'id', item.id
for column in self.columns :
+ value = column.cell_value(item)
+
yield column.attr, dict(
- html = unicode(html(column.cell_html(item))),
- css = tuple(column.cell_css(item)),
- title = column.cell_title(item),
+ html = unicode(html(column.cell_html(item, value))),
+ css = tuple(column.cell_css(item, value)),
+ title = column.cell_title(item, value),
)
class TableHandler (object) :