changeset 348:d3547d33dd32

CollectLists: filter_pattern introduced to select which rows you want in the result
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 03 Feb 2009 18:47:27 +0100
parents a701beab4b9c
children 33cb55aaa955
files data/plugin/macro/CollectLists.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/CollectLists.py	Tue Feb 03 17:15:37 2009 +0100
+++ b/data/plugin/macro/CollectLists.py	Tue Feb 03 18:47:27 2009 +0100
@@ -10,6 +10,8 @@
     or the column_heading. In the latter case the order is used. Also it can optionally use
     another pagename. By setting optional a parser one can use e.g. wikimarkup. By
     filter_selection you can optional use the filter method of the databrowser widget.
+    By using a different filter_pattern than '.*' you get only rows shown where that
+    pattern was found.
 
     @copyright: 2006 by michael cohen <scudette@users.sourceforge.net> (PageDicts)
     @copyright: 2008-2009 by MoinMoin:ReimarBauer (completly rewritten)
@@ -27,6 +29,7 @@
 def macro_CollectLists(macro, pagename=unicode,
                       column_heading=u'', template=u'',
                       transpose=False,
+                      filter_pattern=u'.*',
                       parser=u'text_moin_wiki',
                       filter_selection=u'NeverExistingDefaultFilter'):
 
@@ -81,9 +84,11 @@
         page = Page(request, name)
         page_dict = Dict(request, name)
         row = []
+        tmp_string = []
         for key in column_heading_keys:
             if key in page_dict.keys():
                 value = page_dict.get(key, '')
+                tmp_string.append(value)
                 if WikiParser:
                     # xxx check how our brand new Image class solves this
                     if parser == u'text_moin_wiki':
@@ -95,7 +100,10 @@
                 row.append('')
         parent, child = name.split('/', 1)
         link = page.link_to(request, text="/%s" % child)
-        data.addRow([link] + row)
+        tmp_string = ''.join(tmp_string)
+        search_result = re.search(filter_pattern, tmp_string)
+        if tmp_string and search_result:
+            data.addRow([link] + row)
         if transpose:
             data.columns.extend([Column(link, label=link, align='center')])