[tableview] extract two methods from render_table to ease subclassing
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 24 Oct 2011 13:51:39 +0200
changeset 8014 6ce4ff44b2cf
parent 8013 7b2b8a7fb96d
child 8015 b9de628f90e6
[tableview] extract two methods from render_table to ease subclassing
web/views/tableview.py
--- a/web/views/tableview.py	Mon Oct 24 13:19:23 2011 +0200
+++ b/web/views/tableview.py	Mon Oct 24 13:51:39 2011 +0200
@@ -203,6 +203,20 @@
             facetsform.render(w, vid=self.view.__regid__, cssclass=cssclass,
                               divid=self.view.domid)
 
+    def render_table_headers(self, w, colrenderers):
+        w(u'<thead><tr>')
+        for colrenderer in colrenderers:
+            w(u'<th>')
+            colrenderer.render_header(w)
+            w(u'</th>')
+        w(u'</tr></thead>\n')
+
+    def render_table_body(self, w, colrenderers):
+        w(u'<tbody>')
+        for rownum in xrange(self.view.table_size):
+            self.render_row(w, rownum, colrenderers)
+        w(u'</tbody>')
+
     def render_table(self, w, actions, paginate):
         view = self.view
         divid = view.domid
@@ -217,17 +231,9 @@
         colrenderers = view.build_column_renderers()
         attrs = self.table_attributes()
         w(u'<table %s>' % sgml_attributes(attrs))
-        if view.has_headers:
-            w(u'<thead><tr>')
-            for colrenderer in colrenderers:
-                w(u'<th>')
-                colrenderer.render_header(w)
-                w(u'</th>')
-            w(u'</tr></thead>\n')
-        w(u'<tbody>')
-        for rownum in xrange(view.table_size):
-            self.render_row(w, rownum, colrenderers)
-        w(u'</tbody>')
+        if self.view.has_headers:
+            self.render_table_headers(w, colrenderers)
+        self.render_table_body(w, colrenderers)
         w(u'</table>')
         if actions and self.display_actions == 'bottom':
             self.render_actions(w, actions)