Description
MoinMoin fails when tries to render deprecated page inside some action.
Example
http://master19.moinmo.in/4ct10n/info/SystemPagesInEnglishGroup?action=diff&rev2=117&rev1=116
Component selection
- MoinMoin/Page.py
MoinMoin/theme/init.py
Details
1 Traceback (most recent call last):
2 File "/data/programs/moin.hg-1.9/MoinMoin/wsgiapp.py", line 281, in __call__
3 response = run(context)
4 File "/data/programs/moin.hg-1.9/MoinMoin/wsgiapp.py", line 88, in run
5 response = dispatch(request, context, action_name)
6 File "/data/programs/moin.hg-1.9/MoinMoin/wsgiapp.py", line 136, in dispatch
7 response = handle_action(context, pagename, action_name)
8 File "/data/programs/moin.hg-1.9/MoinMoin/wsgiapp.py", line 195, in handle_action
9 handler(context.page.page_name, context)
10 File "/data/programs/moin.hg-1.9/MoinMoin/action/diff.py", line 222, in execute
11 newpage.send_page(count_hit=0, content_only=1, content_id="content-below-diff")
12 File "/data/programs/moin.hg-1.9/MoinMoin/Page.py", line 1068, in send_page
13 request.theme.add_msg(_('The backed up content of this page is deprecated and will rank lower in search results!'), "warning")
14 File "/data/programs/moin.hg-1.9/MoinMoin/theme/__init__.py", line 1573, in add_msg
15 raise Exception("You cannot call add_msg() after send_title()")
MoinMoin Version |
This Wiki |
OS and Version |
|
Python Version |
|
Server Setup |
|
Server Details |
|
Language you are using the wiki in (set in the browser/UserPreferences) |
|
Workaround
1 --- a/MoinMoin/Page.py Sat Jan 09 02:41:22 2010 +0100
2 +++ b/MoinMoin/Page.py Sat Jan 09 18:32:14 2010 +0300
3 @@ -1065,7 +1065,12 @@
4 if 'deprecated' in pi:
5 # deprecated page, append last backup version to current contents
6 # (which should be a short reason why the page is deprecated)
7 - request.theme.add_msg(_('The backed up content of this page is deprecated and will rank lower in search results!'), "warning")
8 + from MoinMoin.theme import ThemeAddMsgError
9 +
10 + try:
11 + request.theme.add_msg(_('The backed up content of this page is deprecated and will rank lower in search results!'), "warning")
12 + except ThemeAddMsgError:
13 + pass
14
15 revisions = self.getRevList()
16 if len(revisions) >= 2: # XXX shouldn't that be ever the case!? Looks like not.
17 diff -r a88ddb0f486b MoinMoin/theme/__init__.py
18 --- a/MoinMoin/theme/__init__.py Sat Jan 09 02:41:22 2010 +0100
19 +++ b/MoinMoin/theme/__init__.py Sat Jan 09 18:32:14 2010 +0300
20 @@ -21,6 +21,11 @@
21 import sys, xml
22 rss_supported = sys.version_info[:3] >= (2, 5, 1) or '_xmlplus' in xml.__file__
23
24 +class ThemeError(Exception):
25 + """ Base class for theme errors. """
26 +
27 +class ThemeAddMsgError(ThemeError):
28 + """ add_msg() exceptions """
29
30 class ThemeBase:
31 """ Base class for themes
32 @@ -1570,7 +1575,7 @@
33 if not msg_class:
34 msg_class = 'dialog'
35 if self._send_title_called:
36 - raise Exception("You cannot call add_msg() after send_title()")
37 + raise ThemeAddMsgError("You cannot call add_msg() after send_title()")
38 self._status.append((msg, msg_class))
39
40 # stuff from wikiutil.py
41 @@ -1880,7 +1885,7 @@
42 return u'<div class="sidebar">%s</div>' % buffer.getvalue()
43
44
45 -class ThemeNotFound(Exception):
46 +class ThemeNotFound(ThemeError):
47 """ Thrown if the supplied theme could not be found anywhere """
48
49 def load_theme(request, theme_name=None):
Version with logging:
1 --- a/MoinMoin/theme/__init__.py Sat Jan 09 02:41:22 2010 +0100
2 +++ b/MoinMoin/theme/__init__.py Sun Jan 10 01:24:42 2010 +0300
3 @@ -7,6 +7,9 @@
4 """
5
6 import StringIO
7 +
8 +from MoinMoin import log
9 +logging = log.getLogger(__name__)
10
11 from MoinMoin import i18n, wikiutil, config, version, caching
12 from MoinMoin.action import get_available_actions
13 @@ -1570,7 +1573,9 @@
14 if not msg_class:
15 msg_class = 'dialog'
16 if self._send_title_called:
17 - raise Exception("You cannot call add_msg() after send_title()")
18 + logging.error("Calling add_msg() after send_title(): no message can be added.")
19 +
20 + return
21 self._status.append((msg, msg_class))
22
23 # stuff from wikiutil.py
Discussion
Maybe we should just log the error (plus traceback, so we see who called it), not raise an exception.
Plan
- Priority:
- Assigned to:
Status: fixed in http://hg.moinmo.in/moin/1.9/rev/c3822eacfe4a