1.1 --- a/ImprovedTableParser.py Sun Feb 19 00:35:15 2012 +0100
1.2 +++ b/ImprovedTableParser.py Sun Feb 19 00:54:13 2012 +0100
1.3 @@ -9,6 +9,7 @@
1.4 from MoinMoin import wikiutil
1.5 from shlex import shlex
1.6 from StringIO import StringIO
1.7 +from MoinSupport import *
1.8 import re
1.9
1.10 # Regular expressions.
1.11 @@ -350,18 +351,25 @@
1.12 The optional 'attrs' can be used to control the presentation of the table.
1.13 """
1.14
1.15 + # Parse the table region.
1.16 +
1.17 table_attrs, table = parse(text)
1.18
1.19 + # Override any region arguments with request parameters.
1.20 +
1.21 + table_name = attrs.get("name")
1.22 + sortcolumns = table_name and getQualifiedParameter(request, table_name, "sortcolumns") or attrs.get("sortcolumns")
1.23 +
1.24 # Sort the rows according to the values in each of the specified columns.
1.25
1.26 - if attrs.has_key("sortcolumns"):
1.27 + if sortcolumns:
1.28 data_start = int(attrs.get("headers", "1"))
1.29 headers = table[:data_start]
1.30 data = table[data_start:]
1.31
1.32 # Get the sort columns using Unix sort-like notation.
1.33
1.34 - sorter = Sorter(get_sort_columns(attrs["sortcolumns"]))
1.35 + sorter = Sorter(get_sort_columns(sortcolumns))
1.36 data.sort(cmp=sorter)
1.37
1.38 table = headers + data