# HG changeset patch # User Paul Boddie # Date 1329609253 -3600 # Node ID 75990ca1e4c667a7cc54b0574c60a85ec043c62b # Parent 103ec898398ad63df80437cceb8e6a7274358a64 Added support for overriding the table sorting specification using a request parameter prefixed with the calendar name. diff -r 103ec898398a -r 75990ca1e4c6 ImprovedTableParser.py --- a/ImprovedTableParser.py Sun Feb 19 00:35:15 2012 +0100 +++ b/ImprovedTableParser.py Sun Feb 19 00:54:13 2012 +0100 @@ -9,6 +9,7 @@ from MoinMoin import wikiutil from shlex import shlex from StringIO import StringIO +from MoinSupport import * import re # Regular expressions. @@ -350,18 +351,25 @@ The optional 'attrs' can be used to control the presentation of the table. """ + # Parse the table region. + table_attrs, table = parse(text) + # Override any region arguments with request parameters. + + table_name = attrs.get("name") + sortcolumns = table_name and getQualifiedParameter(request, table_name, "sortcolumns") or attrs.get("sortcolumns") + # Sort the rows according to the values in each of the specified columns. - if attrs.has_key("sortcolumns"): + if sortcolumns: data_start = int(attrs.get("headers", "1")) headers = table[:data_start] data = table[data_start:] # Get the sort columns using Unix sort-like notation. - sorter = Sorter(get_sort_columns(attrs["sortcolumns"])) + sorter = Sorter(get_sort_columns(sortcolumns)) data.sort(cmp=sorter) table = headers + data