annotate MoinMoin/macro/__init__.py @ 2507:ea255685d6b0

add macro argument parser and use it to invoke macros with args directly
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sun, 22 Jul 2007 15:58:55 +0200
parents 22749e92a461
children 6de0e14591f7
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - Macro Implementation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
657
016a8a3ef354 wikiutil.MimeType class, renamed parsers to mimetype like module names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 636
diff changeset
5 These macros are used by the wiki parser module to implement complex
016a8a3ef354 wikiutil.MimeType class, renamed parsers to mimetype like module names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 636
diff changeset
6 and/or dynamic page content.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
8 The canonical interface to plugin macros is their execute() function,
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
9 which gets passed an instance of the Macro class. Such an instance
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
10 has the four members parser, formatter, form and request.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
12 Using "form" directly is deprecated and should be replaced by "request.form".
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
13
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
14 @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
15 2006 MoinMoin:ThomasWaldmann
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
19 from MoinMoin.util import pysupport
1133
db56bd53fc32 cleanup plugin related code / attributes, remove unused stuff
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1001
diff changeset
20 modules = pysupport.getPackageModules(__file__)
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
21
510
e1990b501b22 human readable SystemInfo, added disk usage
Thomas Waldmann <tw@waldmann-edv.de>
parents: 413
diff changeset
22 import re, time, os
635
9e17ec23650c moved wikimacro.py to macro/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 615
diff changeset
23 from MoinMoin import action, config, util
636
b77ab6ea0c18 move wikiaction.py to action/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 635
diff changeset
24 from MoinMoin import wikiutil, i18n
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 from MoinMoin.Page import Page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27 names = ["TitleSearch", "WordIndex", "TitleIndex",
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2286
diff changeset
28 "GoTo", "InterWiki", "PageCount",
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 # Macros with arguments
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30 "Icon", "PageList", "Date", "DateTime", "Anchor", "MailTo", "GetVal",
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 "TemplateList",
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 ]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 ### Helpers
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 def getNames(cfg):
1550
a4f0632414da using request.cfg.cache more
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1449
diff changeset
39 if not hasattr(cfg.cache, 'macro_names'):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
40 lnames = names[:]
688
15c55ecd7ccb fix some i18n bugs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 684
diff changeset
41 lnames.extend(i18n.wikiLanguages().keys())
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 lnames.extend(wikiutil.getPlugins('macro', cfg))
1550
a4f0632414da using request.cfg.cache more
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1449
diff changeset
43 cfg.cache.macro_names = lnames # remember it
a4f0632414da using request.cfg.cache more
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1449
diff changeset
44 return cfg.cache.macro_names
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 ### Macros - Handlers for [[macroname]] markup
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 #############################################################################
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 class Macro:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
52 """ Macro handler
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
53
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
54 There are three kinds of macros:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 * Builtin Macros - implemented in this file and named _macro_[name]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 * Language Pseudo Macros - any lang the wiki knows can be use as
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
57 macro and is implemented here by _m_lang()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58 * External macros - implemented in either MoinMoin.macro package, or
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 in the specific wiki instance in the plugin/macro directory
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 """
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
61 defaultDependency = ["time"]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 Dependencies = {
1001
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
64 "TitleSearch": ["namespace"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
65 "Goto": [],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
66 "WordIndex": ["namespace"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
67 "TitleIndex": ["namespace"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
68 "InterWiki": ["pages"], # if interwikimap is editable
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
69 "PageCount": ["namespace"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
70 "Icon": ["user"], # users have different themes and user prefs
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
71 "PageList": ["namespace"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
72 "Date": ["time"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
73 "DateTime": ["time"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
74 "Anchor": [],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
75 "Mailto": ["user"],
ed7febba892b whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 950
diff changeset
76 "GetVal": ["pages"],
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77 "TemplateList": ["namespace"],
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
78 }
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
80 # we need the lang macros to execute when html is generated,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 # to have correct dir and lang html attributes
1870
9406e02388cf reduce usage of .keys()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
82 for lang in i18n.wikiLanguages():
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
83 Dependencies[lang] = []
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
84
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
85
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86 def __init__(self, parser):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 self.parser = parser
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
88 self.form = self.parser.form
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
89 self.request = self.parser.request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
90 self.formatter = self.request.formatter
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
91 self._ = self.request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
92 self.cfg = self.request.cfg
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
93
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
94 # Initialized on execute
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
95 self.name = None
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
96
2507
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
97 def _wrap(self, macro_name, fn, args):
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
98 """
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
99 Parses arguments for a macro call and calls the macro
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
100 function with the arguments.
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
101 """
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
102 if args:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
103 positional, keyword, trailing = \
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
104 wikiutil.parse_quoted_separated(args)
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
105
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
106 kwargs = {}
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
107 nonascii = {}
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
108 for kw in keyword:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
109 try:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
110 kwargs[str(kw)] = keyword[kw]
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
111 except UnicodeEncodeError:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
112 nonascii[kw] = keyword[kw]
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
113
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
114 # add trailing args as keyword argument if present,
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
115 # otherwise remove if the user entered some
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
116 # (so macros don't get a string where they expect a list)
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
117 if trailing:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
118 kwargs['_trailing_args'] = trailing
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
119 elif '_trailing_args' in kwargs:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
120 del kwargs['_trailing_args']
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
121
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
122 # add nonascii args as keyword argument if present,
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
123 # otherwise remove if the user entered some
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
124 # (so macros don't get a string where they expect a list)
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
125 if nonascii:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
126 kwargs['_non_ascii_kwargs'] = nonascii
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
127 elif '_non_ascii_kwargs' in kwargs:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
128 del kwargs['_non_ascii_kwargs']
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
129
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
130 else:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
131 positional = []
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
132 kwargs = {}
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
133
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
134 try:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
135 return fn(self, *positional, **kwargs)
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
136 except TypeError, e:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
137 return u'[[%s]]' % str(e)
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
138 except ValueError, e:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
139 return u'[[%s: %s]]' % (macro_name, str(e))
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
140
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
141 def execute(self, macro_name, args):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
142 """ Get and execute a macro
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
143
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
144 Try to get a plugin macro, or a builtin macro or a language
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
145 macro, or just raise ImportError.
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
146 """
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
147 self.name = macro_name
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
148 try:
2507
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
149 try:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
150 call = wikiutil.importPlugin(self.cfg, 'macro', macro_name,
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
151 function='macro_%s' % macro_name)
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
152 execute = lambda _self, _args: _self._wrap(macro_name, call, _args)
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
153 except wikiutil.PluginAttributeError:
ea255685d6b0 add macro argument parser and use it to invoke macros with args directly
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
154 execute = wikiutil.importPlugin(self.cfg, 'macro', macro_name)
53
699811601bed merge moin--main--1.3--patch-934,935: detect correctly missing plguins and missing names in plugins
Nir Soffer <nirs@freeshell.org>
parents: 51
diff changeset
155 except wikiutil.PluginMissingError:
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
156 try:
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
157 builtins = self.__class__
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
158 execute = getattr(builtins, '_macro_' + macro_name)
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
159 except AttributeError:
688
15c55ecd7ccb fix some i18n bugs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 684
diff changeset
160 if macro_name in i18n.wikiLanguages():
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
161 execute = builtins._m_lang
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
162 else:
53
699811601bed merge moin--main--1.3--patch-934,935: detect correctly missing plguins and missing names in plugins
Nir Soffer <nirs@freeshell.org>
parents: 51
diff changeset
163 raise ImportError("Cannot load macro %s" % macro_name)
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
164 return execute(self, args)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
165
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
166 def _m_lang(self, text):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
167 """ Set the current language for page content.
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
168
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
169 Language macro are used in two ways:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
170 * [lang] - set the current language until next lang macro
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
171 * [lang(text)] - insert text with specific lang inside page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
172 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
173 if text:
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
174 return (self.formatter.lang(1, self.name) +
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
175 self.formatter.text(text) +
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
176 self.formatter.lang(0, self.name))
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
177
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
178 self.request.current_lang = self.name
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
179 return ''
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
180
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
181 def get_dependencies(self, macro_name):
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
182 if macro_name in self.Dependencies:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
183 return self.Dependencies[macro_name]
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
184 try:
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
185 return wikiutil.importPlugin(self.request.cfg, 'macro',
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
186 macro_name, 'Dependencies')
53
699811601bed merge moin--main--1.3--patch-934,935: detect correctly missing plguins and missing names in plugins
Nir Soffer <nirs@freeshell.org>
parents: 51
diff changeset
187 except wikiutil.PluginError:
51
54d5932d5a03 merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action
Nir Soffer <nirs@freeshell.org>
parents: 39
diff changeset
188 return self.defaultDependency
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
189
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
190 def _macro_TitleSearch(self, args):
1924
5dc0896d145a search: fixed wrong import
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
191 from MoinMoin.macro.FullSearch import search_box
1217
237ca54182a7 copied code for search box over to macro/FullSearch.py
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1198
diff changeset
192 return search_box("titlesearch", self)
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
193
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
194 def _macro_GoTo(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
195 """ Make a goto box
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
196
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
197 @param args: macro arguments
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
198 @rtype: unicode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
199 @return: goto box html fragment
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
200 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
201 _ = self._
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
202 html = [
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
203 u'<form method="get" action="">',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
204 u'<div>',
615
fb4240ec8361 make goto an action (1 special case less)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 513
diff changeset
205 u'<input type="hidden" name="action" value="goto">',
fb4240ec8361 make goto an action (1 special case less)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 513
diff changeset
206 u'<input type="text" name="target" size="30">',
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
207 u'<input type="submit" value="%s">' % _("Go To Page"),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
208 u'</div>',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
209 u'</form>',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
210 ]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
211 html = u'\n'.join(html)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
212 return self.formatter.rawHTML(html)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
213
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
214 def _make_index(self, args, word_re=u'.+'):
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
215 """ make an index page (used for TitleIndex and WordIndex macro)
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
216
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
217 word_re is a regex used for splitting a pagename into fragments
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
218 matched by it (used for WordIndex). For TitleIndex, we just match
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
219 the whole page name, so we only get one fragment that is the same
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
220 as the pagename.
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
221
1832
b180f047d918 comments only: cleaned up TODO, XXX, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1805
diff changeset
222 TODO: _make_index could get a macro on its own, more powerful / less special than WordIndex and TitleIndex.
b180f047d918 comments only: cleaned up TODO, XXX, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1805
diff changeset
223 It should be able to filter for specific mimetypes, maybe match pagenames by regex (replace PageList?), etc.
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
224 """
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
225 _ = self._
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
226 request = self.request
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
227 fmt = self.formatter
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
228 allpages = int(self.form.get('allpages', [0])[0]) != 0
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
229 # Get page list readable by current user, filter by isSystemPage if needed
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
230 if allpages:
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
231 pages = request.rootpage.getPageList()
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
232 else:
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
233 def nosyspage(name):
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
234 return not wikiutil.isSystemPage(request, name)
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
235 pages = request.rootpage.getPageList(filter=nosyspage)
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
236
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
237 word_re = re.compile(word_re, re.UNICODE)
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
238 wordmap = {}
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
239 for name in pages:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
240 for word in word_re.findall(name):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
241 try:
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
242 if not wordmap[word].count(name):
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
243 wordmap[word].append(name)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
244 except KeyError:
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
245 wordmap[word] = [name]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
246
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
247 # Sort ignoring case
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
248 tmp = [(word.upper(), word) for word in wordmap]
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
249 tmp.sort()
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
250 all_words = [item[1] for item in tmp]
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
251
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
252 index_letters = []
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
253 current_letter = None
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
254 output = []
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
255 for word in all_words:
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
256 letter = wikiutil.getUnicodeIndexGroup(word)
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
257 if letter != current_letter:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
258 cssid = "idx" + wikiutil.quoteWikinameURL(letter).replace('%', '')
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
259 output.append(fmt.heading(1, 2, id=cssid)) # fmt.anchordef didn't work
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
260 output.append(fmt.text(letter.replace('~', 'Others')))
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
261 output.append(fmt.heading(0, 2))
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
262 current_letter = letter
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
263 if letter not in index_letters:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
264 index_letters.append(letter)
1958
aa3e4fb31c62 WordIndex/TitleIndex: fix wrong attr name
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1924
diff changeset
265 links = wordmap[word]
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
266 if len(links) and links[0] != word: # show word fragment as on WordIndex
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
267 output.append(fmt.strong(1))
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
268 output.append(word)
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
269 output.append(fmt.strong(0))
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
270
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
271 output.append(fmt.bullet_list(1))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
272 links.sort()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
273 last_page = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
274 for name in links:
28
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
275 if name == last_page:
ef8b90110f33 WordIndex: make systempages excludeable
Thomas Waldmann <tw@waldmann-edv.de>
parents: 27
diff changeset
276 continue
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
277 output.append(fmt.listitem(1))
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
278 output.append(Page(request, name).link_to(request, attachment_indicator=1))
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
279 output.append(fmt.listitem(0))
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
280 output.append(fmt.bullet_list(0))
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
281
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
282 def _make_index_key(index_letters):
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
283 index_letters.sort()
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
284 def letter_link(ch):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
285 cssid = "idx" + wikiutil.quoteWikinameURL(ch).replace('%', '')
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
286 return fmt.anchorlink(1, cssid) + fmt.text(ch.replace('~', 'Others')) + fmt.anchorlink(0)
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
287 links = [letter_link(letter) for letter in index_letters]
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
288 return ' | '.join(links)
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
289
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
290 page = fmt.page
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
291 allpages_txt = (_('Include system pages'), _('Exclude system pages'))[allpages]
2226
cff573edd028 fixed wrong link generation for WordIndex/TitleIndex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2207
diff changeset
292 allpages_url = page.url(request, querystr={'allpages': allpages and '0' or '1'}, relative=False)
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
293
1785
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
294 output = [fmt.paragraph(1), _make_index_key(index_letters), fmt.linebreak(0),
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
295 fmt.url(1, allpages_url), fmt.text(allpages_txt), fmt.url(0), fmt.paragraph(0)] + output
e54f99c9beba make TitleIndex/WordIndex use the formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1674
diff changeset
296 return u''.join(output)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
297
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
298
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
299 def _macro_TitleIndex(self, args):
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
300 return self._make_index(args)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
301
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
302 def _macro_WordIndex(self, args):
2207
7ae581d79352 updated bot useragents list, reduce bot cpu usage of some macros (ported from 1.5 repo)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1965
diff changeset
303 if self.request.isSpiderAgent: # reduce bot cpu usage
7ae581d79352 updated bot useragents list, reduce bot cpu usage of some macros (ported from 1.5 repo)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1965
diff changeset
304 return ''
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
305 word_re = u'[%s][%s]+' % (config.chars_upper, config.chars_lower)
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
306 return self._make_index(args, word_re=word_re)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
307
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
308
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
309 def _macro_PageList(self, needle):
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
310 from MoinMoin import search
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
311 _ = self._
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
312 case = 0
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
313
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
314 # If called with empty or no argument, default to regex search for .+, the full page list.
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
315 if not needle:
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
316 needle = 'regex:.+'
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
317
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
318 # With whitespace argument, return same error message as FullSearch
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
319 elif needle.isspace():
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
320 err = _('Please use a more selective search term instead of {{{"%s"}}}') % needle
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
321 return '<span class="error">%s</span>' % err
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
322
735
e3c44dc8f488 merge common code of TitleIndex and WordIndex into _make_index
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 688
diff changeset
323 # Return a title search for needle, sorted by name.
919
5469c8b911a4 Splitting out MoinMoin/search.py to MoinMoin/search/*.py
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 828
diff changeset
324 results = search.searchPages(self.request, needle,
1449
e219092e1a0d a few small fixes to get misc things working with xapian
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1347
diff changeset
325 titlesearch=1, case=case, sort='page_name')
1189
0e352443948b make FullSearch macro work again (without paging)
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 950
diff changeset
326 return results.pageList(self.request, self.formatter, paging=False)
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
327
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
328 def _macro_InterWiki(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
329 from StringIO import StringIO
828
902c34d95085 quoting for attachment filenames, wikiutil.load_wikimap, split_wiki can parse quoting, join_wiki does url_quote
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 753
diff changeset
330 interwiki_list = wikiutil.load_wikimap(self.request)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
331 buf = StringIO()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
332 buf.write('<dl>')
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
333 iwlist = interwiki_list.items() # this is where we cached it
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
334 iwlist.sort()
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
335 for tag, url in iwlist:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
336 buf.write('<dt><tt><a href="%s">%s</a></tt></dt>' % (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
337 wikiutil.join_wiki(url, 'RecentChanges'), tag))
1183
bc84eae93f8c replace usage of find by 'in' operator
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1133
diff changeset
338 if '$PAGE' not in url:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
339 buf.write('<dd><tt><a href="%s">%s</a></tt></dd>' % (url, url))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
340 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
341 buf.write('<dd><tt>%s</tt></dd>' % url)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
342 buf.write('</dl>')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
343 return self.formatter.rawHTML(buf.getvalue())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
344
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
345 def _macro_PageCount(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
346 """ Return number of pages readable by current user
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
347
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
348 Return either an exact count (slow!) or fast count including
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 deleted pages.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
350 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
351 # Check input
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
352 options = {None: 0, '': 0, 'exists': 1}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
353 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
354 exists = options[args]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
355 except KeyError:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
356 # Wrong argument, return inline error message
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
357 arg = self.formatter.text(args)
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 138
diff changeset
358 return (self.formatter.span(1, css_class="error") +
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 138
diff changeset
359 'Wrong argument: %s' % arg +
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 138
diff changeset
360 self.formatter.span(0))
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
361
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
362 count = self.request.rootpage.getPageCount(exists=exists)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
363 return self.formatter.text("%d" % count)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
364
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
365 def _macro_Icon(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
366 icon = args.lower()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
367 return self.formatter.icon(icon)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
368
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
369 def _macro_TemplateList(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
370 _ = self._
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
371 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
372 needle_re = re.compile(args or '', re.IGNORECASE)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
373 except re.error, e:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
374 return "<strong>%s: %s</strong>" % (
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
375 _("ERROR in regex '%s'") % (args, ), e)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
376
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
377 # Get page list readable by current user, filtered by needle
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
378 hits = self.request.rootpage.getPageList(filter=needle_re.search)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
379 hits.sort()
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
380
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
381 result = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
382 result.append(self.formatter.bullet_list(1))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
383 for pagename in hits:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
384 result.append(self.formatter.listitem(1))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
385 result.append(self.formatter.pagelink(1, pagename, generated=1))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
386 result.append(self.formatter.text(pagename))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
387 result.append(self.formatter.pagelink(0, pagename))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
388 result.append(self.formatter.listitem(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
389 result.append(self.formatter.bullet_list(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
390 return ''.join(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
391
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
392
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
393 def __get_Date(self, args, format_date):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
394 _ = self._
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
395 if not args:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
396 tm = time.time() # always UTC
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
397 elif len(args) >= 19 and args[4] == '-' and args[7] == '-' \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
398 and args[10] == 'T' and args[13] == ':' and args[16] == ':':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
399 # we ignore any time zone offsets here, assume UTC,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
400 # and accept (and ignore) any trailing stuff
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 try:
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
402 year, month, day = int(args[0:4]), int(args[5:7]), int(args[8:10])
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
403 hour, minute, second = int(args[11:13]), int(args[14:16]), int(args[17:19])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
404 tz = args[19:] # +HHMM, -HHMM or Z or nothing (then we assume Z)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
405 tzoffset = 0 # we assume UTC no matter if there is a Z
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
406 if tz:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
407 sign = tz[0]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
408 if sign in '+-':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
409 tzh, tzm = int(tz[1:3]), int(tz[3:])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
410 tzoffset = (tzh*60+tzm)*60
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
411 if sign == '-':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
412 tzoffset = -tzoffset
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
413 tm = (year, month, day, hour, minute, second, 0, 0, 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
414 except ValueError, e:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
415 return "<strong>%s: %s</strong>" % (
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
416 _("Bad timestamp '%s'") % (args, ), e)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
417 # as mktime wants a localtime argument (but we only have UTC),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
418 # we adjust by our local timezone's offset
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
420 tm = time.mktime(tm) - time.timezone - tzoffset
1805
ebcebba1afb3 removed some unused attributes, used 'dummy' for dummies
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1794
diff changeset
421 except (OverflowError, ValueError):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
422 tm = 0 # incorrect, but we avoid an ugly backtrace
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
423 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
424 # try raw seconds since epoch in UTC
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
425 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
426 tm = float(args)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
427 except ValueError, e:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
428 return "<strong>%s: %s</strong>" % (
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
429 _("Bad timestamp '%s'") % (args, ), e)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
430 return format_date(tm)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
431
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
432 def _macro_Date(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
433 return self.__get_Date(args, self.request.user.getFormattedDate)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
434
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
435 def _macro_DateTime(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
436 return self.__get_Date(args, self.request.user.getFormattedDateTime)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
437
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
438 def _macro_Anchor(self, args):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
439 return self.formatter.anchordef(args or "anchor")
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
440
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
441 def _macro_MailTo(self, args):
753
d48400378d4c fixed MailTo macro import
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 735
diff changeset
442 from MoinMoin.mail.sendmail import decodeSpamSafeEmail
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
443 result = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
444 args = args or ''
1183
bc84eae93f8c replace usage of find by 'in' operator
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1133
diff changeset
445 if ',' not in args:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
446 email = args
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
447 text = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
448 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
449 email, text = args.split(',', 1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
450
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
451 email, text = email.strip(), text.strip()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
452
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
453 if self.request.user.valid:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
454 # decode address and generate mailto: link
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
455 email = decodeSpamSafeEmail(email)
410
1a2bd0457cf3 fix some wrong attributes, todo: fix quoting, see comment in text_html.url
Thomas Waldmann <tw@waldmann-edv.de>
parents: 407
diff changeset
456 result = (self.formatter.url(1, 'mailto:' + email, css='mailto', do_escape=0) +
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
457 self.formatter.text(text or email) +
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
458 self.formatter.url(0))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
459 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
460 # unknown user, maybe even a spambot, so
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
461 # just return text as given in macro args
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
462
1674
a45b23e6217d minor MailTo macro change from docbook branch
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1550
diff changeset
463 if text:
a45b23e6217d minor MailTo macro change from docbook branch
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1550
diff changeset
464 result = self.formatter.text(text+" ")
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2226
diff changeset
465
1674
a45b23e6217d minor MailTo macro change from docbook branch
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1550
diff changeset
466 result += self.formatter.code(1) + \
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
467 self.formatter.text("<%s>" % email) + \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
468 self.formatter.code(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
469
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
470 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
471
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
472 def _macro_GetVal(self, args):
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
473 page, key = args.split(',')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
474 d = self.request.dicts.dict(page)
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 919
diff changeset
475 result = d.get(key, '')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
476 return self.formatter.text(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
477