Description
The format method in the text_creole Parser class has a different signature than the same method in the text_moin_wiki Parser class. This causes wikiutil.renderText to fail with the Parser parameter is set to text_creole.
Steps to reproduce
- Create a simple macro like:
from MoinMoin.Page import Page from MoinMoin import wikiutil Dependencies = ["namespace"] def macro_text(macro, page_name, parser=u'text_moin_wiki',): request = macro.request formatter = macro.formatter try: WikiParser = wikiutil.importPlugin(request.cfg, 'parser', parser, function="Parser") except wikiutil.PluginMissingError: WikiParser = None page = Page(request, page_name) if page is None: return '' if not request.user.may.read(page_name): return '' else: return wikiutil.renderText(request, WikiParser, page.getPageText())
Create a page A like (change SomeWikiPage to a page name with moin wiki markup):
Test Page A: <<Test(SomeWikiPage)>>
Create a page B like (change SomeCreolePage to a page name with creole markup):
#format text/creole Test Page B: <<Test(SomeCreolePage, "text_creole")>>
Page A will render SomeWikiPage
Page B will throw an exception indicating that format received and invalid parameter inhibit_p
Example
Component selection
Problem appears to be in the signature of format in text_creole.py
Details
MoinMoin Version |
1.9.3 |
OS and Version |
|
Python Version |
2.6 |
Server Setup |
|
Server Details |
|
Language you are using the wiki in (set in the browser/UserPreferences) |
|
Workaround
Changing the signature of format in text_creole.py works around the problem.
def format(self, formatter, inhibit_p = False):
Of course the format method doesn't yet use the parameter so changing the value won't have any effect.
Discussion
We need a better solution for this, as it not only affects the creole parser or other builtin parsers, but ALL parsers in general.
fix it for all places
1 diff -r 62202e5435e2 MoinMoin/parser/_ParserBase.py
2 --- a/MoinMoin/parser/_ParserBase.py Tue Jul 05 20:07:18 2011 +0200
3 +++ b/MoinMoin/parser/_ParserBase.py Fri Jul 29 13:20:58 2011 +0200
4 @@ -196,7 +196,7 @@
5 fmt = FormatText(name)
6 self.rule_fmt[name] = fmt
7
8 - def format(self, formatter, form=None):
9 + def format(self, formatter, form=None, inhibit_p=None):
10 """ Send the text.
11 """
12
13 diff -r 62202e5435e2 MoinMoin/parser/highlight.py
14 --- a/MoinMoin/parser/highlight.py Tue Jul 05 20:07:18 2011 +0200
15 +++ b/MoinMoin/parser/highlight.py Fri Jul 29 13:20:58 2011 +0200
16 @@ -152,7 +152,7 @@
17 params = format_args
18 self.show_nums, self.num_start, self.num_step, attrs = parse_start_step(request, params)
19
20 - def format(self, formatter):
21 + def format(self, formatter, inhibit_p=None):
22 _ = self.request.getText
23 fmt = PygmentsFormatter(formatter, start_line=self.start_line)
24
25 diff -r 62202e5435e2 MoinMoin/parser/text.py
26 --- a/MoinMoin/parser/text.py Tue Jul 05 20:07:18 2011 +0200
27 +++ b/MoinMoin/parser/text.py Fri Jul 29 13:20:58 2011 +0200
28 @@ -29,7 +29,7 @@
29 self._ = request.getText
30 self.start_line = kw.get('start_line', 0)
31
32 - def format(self, formatter):
33 + def format(self, formatter, inhibit_p=None):
34 """ Send the text. """
35
36 self.lines = self.raw.expandtabs().split('\n')
37 diff -r 62202e5435e2 MoinMoin/parser/text_creole.py
38 --- a/MoinMoin/parser/text_creole.py Tue Jul 05 20:07:18 2011 +0200
39 +++ b/MoinMoin/parser/text_creole.py Fri Jul 29 13:20:58 2011 +0200
40 @@ -64,7 +64,7 @@
41 self.rules = MoinRules(wiki_words=True,
42 url_protocols=config.url_schemas)
43
44 - def format(self, formatter):
45 + def format(self, formatter, inhibit_p=None):
46 """Create and call the true parser and emitter."""
47
48 document = CreoleParser(self.raw, self.rules).parse()
49 diff -r 62202e5435e2 MoinMoin/parser/text_csv.py
50 --- a/MoinMoin/parser/text_csv.py Tue Jul 05 20:07:18 2011 +0200
51 +++ b/MoinMoin/parser/text_csv.py Fri Jul 29 13:20:58 2011 +0200
52 @@ -182,7 +182,7 @@
53 data.addRow(tuple(row))
54 self.data = data
55
56 - def format(self, formatter):
57 + def format(self, formatter, inhibit_p=None):
58 browser = DataBrowserWidget(self.request, show_header=self._show_header)
59 browser.setData(self.data)
60 self.request.write(browser.render(method="GET"))
61 diff -r 62202e5435e2 MoinMoin/parser/text_docbook.py
62 --- a/MoinMoin/parser/text_docbook.py Tue Jul 05 20:07:18 2011 +0200
63 +++ b/MoinMoin/parser/text_docbook.py Fri Jul 29 13:20:58 2011 +0200
64 @@ -59,7 +59,7 @@
65 self.wikiParser = WikiParser(raw=self.raw, request=self.request, pretty_url=1)
66 self.key = 'docbook'
67
68 - def format(self, formatter):
69 + def format(self, formatter, inhibit_p=None):
70 self.wikiParser.formatter = formatter
71 XsltParser.format(self, formatter)
72
73 diff -r 62202e5435e2 MoinMoin/parser/text_html.py
74 --- a/MoinMoin/parser/text_html.py Tue Jul 05 20:07:18 2011 +0200
75 +++ b/MoinMoin/parser/text_html.py Fri Jul 29 13:20:58 2011 +0200
76 @@ -23,7 +23,7 @@
77 self.raw = raw
78 self.request = request
79
80 - def format(self, formatter):
81 + def format(self, formatter, inhibit_p=None):
82 """ Send the text. """
83 try:
84 self.request.write(formatter.rawHTML(Markup(self.raw).sanitize()))
85 diff -r 62202e5435e2 MoinMoin/parser/text_rst.py
86 --- a/MoinMoin/parser/text_rst.py Tue Jul 05 20:07:18 2011 +0200
87 +++ b/MoinMoin/parser/text_rst.py Fri Jul 29 13:20:58 2011 +0200
88 @@ -200,7 +200,7 @@
89 self.request = request
90 self.form = request.form
91
92 - def format(self, formatter):
93 + def format(self, formatter, inhibit_p=None):
94 # Create our simple parser
95 parser = MoinDirectives(self.request)
96
97 diff -r 62202e5435e2 MoinMoin/parser/text_xslt.py
98 --- a/MoinMoin/parser/text_xslt.py Tue Jul 05 20:07:18 2011 +0200
99 +++ b/MoinMoin/parser/text_xslt.py Fri Jul 29 13:20:58 2011 +0200
100 @@ -36,7 +36,7 @@
101 self.base_uri = 'wiki://Self/'
102 self.key = 'xslt'
103
104 - def format(self, formatter):
105 + def format(self, formatter, inhibit_p=None):
106 """ Send the text. """
107 _ = self._
108
Plan
- Priority:
- Assigned to:
Status: reopen if not fixed by http://hg.moinmo.in/moin/1.9/rev/ff39884957af