Mercurial > moin > extensions
annotate data/plugin/macro/DictColumns.py @ 654:8c828d7b6cd4 tip
PDFList: check for pyPdf.utils.PdfReadError
author  Reimar Bauer <rb.proj AT googlemail DOT com> 

date  Wed, 07 Dec 2016 14:27:25 +0100 
parents  127da830be6c 
children 
rev  line source 

506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

1 # * coding: iso88591 * 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

2 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

3 MoinMoin  macro to collect data from definition lists on pages 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

4 into a data browser widget table 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

5 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

6 <<DictColumns(search_term=regex:title:^Examplepage/)> 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

7 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

8 @copyright: 2006 by michael cohen <scudette@users.sourceforge.net> (PageDicts) 
653
127da830be6c
updated copyright
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
561
diff
changeset

9 @copyright: 20082016 by MoinMoin:ReimarBauer (completly rewritten) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

10 @license: GNU GPL, see COPYING for details. 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

11 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

12 import re 
545
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

13 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

14 from collections import defaultdict 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

15 from MoinMoin import wikiutil, search 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

16 from MoinMoin.Page import Page 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

17 from MoinMoin.action.SlideShow import SlidePage 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

18 from MoinMoin.util.dataset import TupleDataset, Column 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

19 from MoinMoin.widget.browser import DataBrowserWidget 
545
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

20 from MoinMoin.datastruct.backends.wiki_dicts import WikiDicts 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

21 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

22 Dependencies = ["pages"] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

23 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

24 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

25 def _csv2list(csv): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

26 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

27 converts a string of comma separated values into a list 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

28 @param csv: string of comma separated values 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

29 @returns: list 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

30 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

31 csv_list = csv.split(',') 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

32 return [variable.strip() for variable in csv_list if variable.strip()] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

33 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

34 def _name2index(all_names, selected_names): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

35 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

36 converts names to the index 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

37 @param all_names: all available names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

38 @param selected_names: names to lookup index position of all_names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

39 @return: list of indices 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

40 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

41 if selected_names: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

42 try: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

43 index = [all_names.index(name) for name in selected_names] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

44 except ValueError: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

45 return [] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

46 return index 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

47 return [] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

48 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

49 class DictColumns(object): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

50 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

51 Collects definition list key and values pairs. 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

52 Each key becomes a column with its values. 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

53 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

54 def __init__(self, macro, pagename=u'', title=u'', names=u'', 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

55 sort=u'', reverse=u'', 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

56 hide=u'', filter_name=u'NeverExistingDefaultFilter', 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

57 filter_value=u'', template_page=u'', alias_page=u'', 
559
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

58 parser=u'text_moin_wiki', markup="definition list", 
560
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

59 search_term=None, comments=False, enumeration=False): 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

60 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

61 self.formatter = macro.formatter 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

62 self.request = macro.request 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

63 self.pagename = pagename 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

64 if not pagename: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

65 self.pagename = macro.formatter.page.page_name 
541
df335ad9a37d
macro.DictColumns: add page obeject to request object
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
523
diff
changeset

66 self.request.page = Page(self.request, self.pagename) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

67 self.title = title 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

68 if not title: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

69 self.title = self.pagename 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

70 self.names = names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

71 self.sort = sort 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

72 self.reverse = reverse 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

73 self.hide = hide 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

74 self.filter_name = filter_name 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

75 self.filter_value = filter_value 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

76 self.filter_key, self.filter_word = (u"", u"") 
559
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

77 self.comments = comments 
560
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

78 self.enumeration = enumeration 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

79 regex = re.compile(ur'(?P<key>\w*)=(?P<value>.*)', re.UNICODE) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

80 try: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

81 self.filter_key, self.filter_word = regex.search(filter_value).groups() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

82 except AttributeError: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

83 # Don't filter if syntax was wrong 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

84 self.filter_value = u"" 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

85 self.template_page = template_page 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

86 self.alias_page = alias_page 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

87 try: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

88 self.wiki_parser = wikiutil.importPlugin( 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

89 self.request.cfg, "parser", 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

90 parser, function="Parser") 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

91 except wikiutil.PluginMissingError: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

92 self.wiki_parser = None 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

93 self.search_term = search_term 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

94 self.markup = markup 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

95 if search_term is None: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

96 self.search_term = u'regex:title:^%s/' % self.pagename 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

97 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

98 def get_dict(self, dict_source): 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

99 """ 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

100 gets the dictionary dependent of the markup 
512
31e327c450ca
PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
511
diff
changeset

101 @param dict_source: pagename to read dict data from 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

102 """ 
545
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

103 if self.markup in ("definition list", "dl"): 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

104 return self.request.dicts[dict_source] 
545
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

105 elif self.markup in ("multiline definition list", "mdl"): 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

106 return self.parse_multiline_dict(dict_source) 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

107 elif self.markup in ("title", "t"): 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

108 return self.parse_title(dict_source) 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

109 
545
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

110 def parse_multiline_dict(self, dict_source): 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

111 """ 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

112 creates a dictionary based on a definition list with multiple entries of the same key. 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

113 The type of the value is a list 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

114 a:: 1 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

115 b:: 1 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

116 b:: 2 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

117 b:: 3 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

118 c:: 4 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

119 @param dict_source: pagename to read dict data from 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

120 """ 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

121 body = Page(self.request, dict_source).get_raw_body() 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

122 ddict = defaultdict(list) 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

123 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

124 for match in WikiDicts._dict_page_parse_regex.finditer(body): 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

125 key, value = match.groups() 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

126 ddict[key].append(value) 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

127 return ddict 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

128 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

129 def parse_title(self, dict_source): 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

130 """ 
512
31e327c450ca
PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
511
diff
changeset

131 creates a dictionary based on page titles 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

132 @param dict_source: pagename to read dict data from 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

133 """ 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

134 body = Page(self.request, dict_source).get_raw_body() 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

135 parser = SlidePage(self.request, dict_source).createSlideParser() 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

136 ddict = {} 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

137 for title, bodyStart, bodyEnd in parser.parse(body): 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

138 ddict[title] = body[bodyStart:bodyEnd].strip() 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

139 return ddict 
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

140 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

141 def get_page_list(self): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

142 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

143 selects the pages dependent on a search term, 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

144 without listing of template, dictionary pages and 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

145 the pagename itselfs. 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

146 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

147 request = self.request 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

148 search_term = self.search_term 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

149 search_result = search.searchPages(request, search_term) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

150 pages = [title.page_name for title in search_result.hits] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

151 if not pages: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

152 return None 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

153 # exclude some_pages 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

154 filterfn = request.cfg.cache.page_template_regexact.search 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

155 template_pages = request.rootpage.getPageList(filter=filterfn) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

156 excluded_pages = template_pages + [self.alias_page, self.pagename] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

157 selected_pages = [page for page in pages if page not in excluded_pages] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

158 selected_pages.sort() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

159 return selected_pages 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

160 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

161 def get_names(self, selected_pages): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

162 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

163 selects which column names should be used 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

164 @param selected_pages: list of page names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

165 @return: list of names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

166 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

167 request = self.request 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

168 # use selection and order 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

169 if self.names: 
521
64d08878782b
macro.DictColumns: simplified get_names (keeping order of names)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
512
diff
changeset

170 return self.names 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

171 # use keys from template page, no order 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

172 elif Page(request, self.template_page).exists(): 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

173 page_dict = self.get_dict(self.template_page) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

174 names = page_dict.keys() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

175 else: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

176 # fallback use the keys used on selected pages 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

177 names = [] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

178 for page_name in selected_pages: 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

179 page_dict = self.get_dict(page_name) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

180 keys = page_dict.keys() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

181 names = names + keys 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

182 return list(set(names)) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

183 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

184 def dataset(self, names, selected_pages): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

185 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

186 Sets the data for the data browser widget 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

187 @param names: column names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

188 @param selected_pages: pages to read key value pairs from 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

189 """ 
561
6a0ea7cf7c43
extensions.macro.DictColumns: i18n for Comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
560
diff
changeset

190 _ = self.request.getText 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

191 assert isinstance(selected_pages, list) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

192 request = self.request 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

193 hide_columns = self.hide 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

194 # default alias 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

195 alias_dict = {} 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

196 for name in names: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

197 alias_dict[name] = name 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

198 if Page(request, self.alias_page).exists(): 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

199 alias = self.get_dict(self.alias_page) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

200 for name in names: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

201 alias_dict[name] = alias.get(name, name) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

202 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

203 col = Column(self.title, label=self.title) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

204 if self.title in hide_columns: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

205 col.hidden = True 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

206 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

207 data = TupleDataset() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

208 data.columns = [] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

209 data.columns.extend([col]) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

210 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

211 for page_name in selected_pages: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

212 page = Page(request, page_name) 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

213 page_dict = self.get_dict(page_name) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

214 if self.filter_value and page_dict.get(self.filter_key, '') != self.filter_word: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

215 continue 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

216 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

217 row = [] 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

218 for name in names: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

219 if name in page_dict.keys(): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

220 value = page_dict.get(name, '') 
545
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

221 if isinstance(value, list) and len(value) > 1: 
546
ca0f831afd76
DictColumns: mdl markup of multiple elements in table changed to enumeration
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
545
diff
changeset

222 value = ' 1. %s' % '\n 1. '.join(value) 
545
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

223 elif isinstance(value, list): 
946737f9eb1b
DictColumns: new parser for multiline definition list (markup=mdl) introduced,
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
541
diff
changeset

224 value = value[0] 
522
0d5369896835
macro.DictColumns: also for extensions macro Image use the page_name of the image similar to the attachment:
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
512
diff
changeset

225 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

226 if self.wiki_parser: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

227 row.append((wikiutil.renderText(request, self.wiki_parser, value), 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

228 wikiutil.escape(value, 1))) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

229 else: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

230 row.append('') 
559
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

231 if self.comments: 
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

232 row.append('') 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

233 try: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

234 parent, child = page_name.split('/', 1) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

235 except ValueError: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

236 child = page_name 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

237 link = page.link_to(request, text="%s" % child) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

238 data.addRow([link] + row) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

239 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

240 if self.filter_name: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

241 filtercols = self.filter_name 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

242 for name in names: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

243 if self.filter_name != u'NeverExistingDefaultFilter' and name in filtercols: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

244 col = Column(alias_dict[name], autofilter=(name in filtercols)) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

245 if name in hide_columns: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

246 col.hidden = True 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

247 data.columns.append(col) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

248 else: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

249 col = Column(alias_dict[name], label=alias_dict[name]) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

250 if name in hide_columns: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

251 col.hidden = True 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

252 data.columns.extend([col]) 
559
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

253 if self.comments: 
561
6a0ea7cf7c43
extensions.macro.DictColumns: i18n for Comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
560
diff
changeset

254 col = Column("Comment", label=_("Comment:")) 
559
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

255 data.columns.extend([col]) 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

256 return data 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

257 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

258 def render(self): 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

259 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

260 renders output as widget data browser table 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

261 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

262 request = self.request 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

263 _ = request.getText 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

264 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

265 selected_pages = self.get_page_list() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

266 if not selected_pages: 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

267 return _("""\ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

268 Please use a more selective search term instead of search_term="%s"\ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

269 """) % self.search_term 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

270 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

271 names = self.get_names(selected_pages) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

272 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

273 data = self.dataset(names, selected_pages) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

274 table = DataBrowserWidget(request) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

275 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

276 names.insert(0, "__name__") 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

277 sort_columns = _name2index(names, self.sort) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

278 sort_reverse_columns = _name2index(names, self.reverse) or False 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

279 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

280 table.setData(data, sort_columns, reverse=sort_reverse_columns) 
560
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

281 if self.enumeration: 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

282 idx = 0 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

283 for line in data.data: 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

284 line.insert(0, unicode(idx + 1)) 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

285 data.data[idx] = line 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

286 idx += 1 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

287 col = Column(" ", label=" ") 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

288 data.columns.insert(0, col) 
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

289 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

290 html = ''.join(table.format(method='GET')) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

291 return html 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

292 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

293 def macro_DictColumns(macro, pagename=unicode, title=u'', names=u'', sort=u'', reverse=u'', 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

294 hide=u'', filter_name=u'NeverExistingDefaultFilter', 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

295 filter_value=u'', template_page=u'', alias_page=u'', 
559
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

296 parser=u'text_moin_wiki', 
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

297 markup=("definition list", "title", 
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

298 "multiline definition list", 
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

299 "dl", "mdl", "t"), 
7fa7120dfcc6
macro.DictColumns: add a comment columns to the result table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
546
diff
changeset

300 comments=False, 
560
f502d6e75c07
macro.DictColumns: optional enumeration of line numbers
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
559
diff
changeset

301 enumeration=False, 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

302 search_term=None): 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

303 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

304 Creates a table by data browser widget from definition lists key value pairs. 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

305 @param pagename: name of the page 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

306 @param title: entry in upper left corner of the table 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

307 @param name: names of columns, key name of definition list (comma separated) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

308 @param sort: name of columns to sort by 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

309 @param reverse: name of columns to reverse sort by 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

310 @param hide: name of columns to hide 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

311 @param filter_name: name of columns to filter by autofilter 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

312 @param filter_value: dict definition for value of column to filter by 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

313 @param template_page: pagename of the template for setting column names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

314 @param alias_page: pagename of the page for setting aliases for column names 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

315 @param parser: name of the parser used to render markup 
511
ef1f74bf4776
macro DictColumns: new keyword markup defined (default is "definition list"). By setting it to "title" the column headings are defined by the titles of the pageThe text below a title becomes assigned to the column.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
506
diff
changeset

316 @param markup: type of markup for separating key value pairs 
506
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

317 @param search_term: regex used to search for selecting pages 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

318 """ 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

319 kw = locals() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

320 # wiki input can be a string with comma separated values. 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

321 kw["names"] = _csv2list(kw["names"]) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

322 kw["sort"] = _csv2list(kw["sort"]) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

323 kw["reverse"] = _csv2list(kw["reverse"]) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

324 kw["hide"] = _csv2list(kw["hide"]) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

325 kw["filter_name"] = _csv2list(kw["filter_name"]) 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

326 html = DictColumns(**kw).render() 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

327 # works together with 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

328 # http://moinmo.in/FeatureRequests/SortableTables?action=AttachFile&do=view&target=common.js.patch 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

329 # html = html.replace('id="dbw.table', 'class="sortable" id="dbw.table') 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

330 return html 
b7a9843c5730
macro DictColumns:Collects definition list key and values pairs. Each key becomes a column with its values.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff
changeset

331 