[tableview] .entity method is useful on EntityTableView as well, move it there
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 27 Oct 2011 10:38:03 +0200
changeset 8028 58e9bc8a1f2c
parent 8027 9ac82788f67b
child 8029 805d4e121b65
[tableview] .entity method is useful on EntityTableView as well, move it there
web/views/tableview.py
--- a/web/views/tableview.py	Thu Oct 27 10:38:02 2011 +0200
+++ b/web/views/tableview.py	Thu Oct 27 10:38:03 2011 +0200
@@ -693,12 +693,12 @@
     def sortvalue(self, rownum):
         entity = self.entity(rownum)
         if entity:
-            return self.sortfunc(self.entity(rownum))
+            return self.sortfunc(entity)
         return None
 
     def entity(self, rownum):
         """Return the table's main entity"""
-        return self.view.cw_rset.get_entity(rownum, self.view.cw_col or 0)
+        return self.view.entity(rownum)
 
 
 class MainEntityColRenderer(EntityTableColRenderer):
@@ -779,6 +779,10 @@
     def build_column_renderers(self):
         return [self.column_renderer(colid) for colid in self.columns]
 
+    def entity(self, rownum):
+        """Return the table's main entity"""
+        return self.cw_rset.get_entity(rownum, self.cw_col or 0)
+
 
 class EmptyCellView(AnyRsetView):
     __regid__ = 'empty-cell'