changeset 560:f502d6e75c07

macro.DictColumns: optional enumeration of line numbers
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 29 Mar 2011 16:38:07 +0200
parents 7fa7120dfcc6
children 6a0ea7cf7c43
files data/plugin/macro/DictColumns.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/DictColumns.py	Tue Mar 29 15:09:43 2011 +0200
+++ b/data/plugin/macro/DictColumns.py	Tue Mar 29 16:38:07 2011 +0200
@@ -56,7 +56,7 @@
                  hide=u'', filter_name=u'NeverExistingDefaultFilter',
                  filter_value=u'', template_page=u'', alias_page=u'',
                  parser=u'text_moin_wiki', markup="definition list",
-                 search_term=None, comments=False):
+                 search_term=None, comments=False, enumeration=False):
 
         self.formatter = macro.formatter
         self.request = macro.request
@@ -75,6 +75,7 @@
         self.filter_value = filter_value
         self.filter_key, self.filter_word = (u"", u"")
         self.comments = comments
+        self.enumeration = enumeration
         regex = re.compile(ur'(?P<key>\w*)=(?P<value>.*)', re.UNICODE)
         try:
             self.filter_key, self.filter_word = regex.search(filter_value).groups()
@@ -276,6 +277,15 @@
         sort_reverse_columns = _name2index(names, self.reverse) or False
 
         table.setData(data, sort_columns, reverse=sort_reverse_columns)
+        if self.enumeration:
+            idx = 0
+            for line in data.data:
+                line.insert(0, unicode(idx + 1))
+                data.data[idx] = line
+                idx += 1
+            col = Column(" ", label=" ")
+            data.columns.insert(0, col)
+
         html = ''.join(table.format(method='GET'))
         return html
 
@@ -287,6 +297,7 @@
                               "multiline definition list",
                               "dl", "mdl", "t"),
                       comments=False,
+                      enumeration=False,
                       search_term=None):
     """
     Creates a table by data browser widget from definition lists key value pairs.