Description
While adding a macro to the footer in modern.py theme I recognized that it won't right execute if the attachfile action is called on a page. -- ReimarBauer 2005-10-22 16:37:45
The error is:
args = ("Formatter instance has no attribute 'page'",)This behaviour was discussed with NirSoffer on the MoinMoinQuestions
Example
#format python
def footer(self, d, **keywords):
""" Assemble wiki footer
@param d: parameter dictionary
@keyword ...:...
@rtype: unicode
@return: page footer html
"""
Parser = wikiutil.importPlugin(self.request.cfg, 'parser', 'wiki', 'Parser')
Hits = Parser('[[Hits]]', self.request).format(self.request.formatter)
page = d['page']
html = [
# End of page
self.pageinfo(page),
self.endPage(),
# Pre footer custom html (not recommended!)
self.emit_custom_html(self.cfg.page_footer1),
# Footer
u'<div id="footer">',
self.editbar(d),
self.credits(d),
self.showversion(d, **keywords),
u'</div>',
# Post footer custom html
self.emit_custom_html(self.cfg.page_footer2),
self.emit_custom_html(str(Hits)),
]
return u'\n'.join(html)
Details
MoinMoin Version |
1.5.0 Patchlevel 129 |
OS and Version |
linux |
Python Version |
2.3.5 |
Server Setup |
cgi-bin |
Server Details |
apache2 |
Workaround
Nirs suggestion was to add this before the wikiutil.importPlugin call.
self.request.formatter.page = d["page"]
Discussion
This is not a MoinMoin bug, it is just a problematic extension:
- the wiki parser/formatter is usually used to parse/format wiki page content
- the footer (and header) area is not page content
- actions do not use the parser, in the worst case they do not even use the formatter
- if an action does not process a page, formatter.page is not used
- if you use content stuff (and a macro is usually content) in the footer, you are using it outside its usual place
Plan
- Priority:
- Assigned to:
- Status:
