changeset 504:31e92294799a

CollectLists: make macro compliant bot with 1.9 and 1.8-.
author Eugene Syromyatnikov <evgsyr@gmail.com>
date Sat, 20 Feb 2010 13:15:01 +0300
parents 84e949d36271
children 944bccb3f184
files data/plugin/macro/CollectLists.py
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/CollectLists.py	Sat Feb 20 10:42:07 2010 +0100
+++ b/data/plugin/macro/CollectLists.py	Sat Feb 20 13:15:01 2010 +0300
@@ -40,11 +40,20 @@
 from MoinMoin import wikiutil, search
 from MoinMoin.Page import Page
 from MoinMoin.util.dataset import TupleDataset, Column
-from MoinMoin.wikidicts import Dict
 from MoinMoin.widget.browser import DataBrowserWidget
 
 Dependencies = ["pages"]
 
+# Using old or new dict engine depending on version.
+try:
+    from MoinMoin.wikidicts import Dict
+
+    def get_dict(request, dict_source):
+        return Dict(request, dict_source)
+except ImportError:
+    def get_dict(request, dict_source):
+        return request.dicts[dict_source]
+
 def sort_table(table, cols=0, reverse=False):
     """
     sorts by column number. If a list is given multiple columns become sorted
@@ -144,12 +153,12 @@
     # use keys from template page
     elif Page(request, template).exists():
         page = Page(request, template)
-        page_dict = Dict(request, template)
+        page_dict = get_dict(request, template)
         column_heading_keys = page_dict.keys()
     else:
         # fallback use the keys of the first subpage
         page = Page(request, subpages[0])
-        page_dict = Dict(request, subpages[0])
+        page_dict = get_dict(request, subpages[0])
         column_heading_keys = page_dict.keys()
 
     # default alias
@@ -157,7 +166,7 @@
     for key in column_heading_keys:
         alias_dict[key] = key
     if Page(request, dictionary).exists():
-        alias_dict = Dict(request, dictionary)
+        alias_dict = get_dict(request, dictionary)
         heading_keys = [alias_dict[key] for key in column_heading_keys]
 
     data = TupleDataset()
@@ -169,7 +178,7 @@
 
     for name in subpages:
         page = Page(request, name)
-        page_dict = Dict(request, name)
+        page_dict = get_dict(request, name)
         if filter_column_value and page_dict.get(filter_key, '') != filter_word:
             continue
         row = []