changeset 2966:ba14d391c2ba

Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but instead the separate patch from http://code.google.com/p/google-highly-open-participation-moinmoin/issues/detail?id=51 should be used.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sun, 23 Dec 2007 23:52:43 +0100
parents 4d60ea3a4ca7
children a310264ad186
files MoinMoin/Page.py MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py MoinMoin/action/AttachFile.py MoinMoin/action/CopyPage.py MoinMoin/action/Despam.py MoinMoin/action/LikePages.py MoinMoin/action/Load.py MoinMoin/action/MyPages.py MoinMoin/action/PackagePages.py MoinMoin/action/RenamePage.py MoinMoin/action/SpellCheck.py MoinMoin/action/SubscribeUser.py MoinMoin/action/SyncPages.py MoinMoin/action/__init__.py MoinMoin/action/backup.py MoinMoin/action/chart.py MoinMoin/action/diff.py MoinMoin/action/edit.py MoinMoin/action/fckdialog.py MoinMoin/action/fullsearch.py MoinMoin/action/login.py MoinMoin/action/logout.py MoinMoin/action/newpage.py MoinMoin/action/quicklink.py MoinMoin/action/revert.py MoinMoin/action/subscribe.py
diffstat 27 files changed, 145 insertions(+), 133 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/Page.py	Sun Dec 23 23:52:43 2007 +0100
@@ -992,12 +992,11 @@
         request.emit_http_headers()
         request.write(text)
 
-    def send_page(self, msg=None, **keywords):
+    def send_page(self, **keywords):
         """ Output the formatted page.
 
         TODO: "kill send_page(), quick" (since 2002 :)
 
-        @param msg: if given, display message in header area
         @keyword content_only: if 1, omit http headers, page header and footer
         @keyword content_id: set the id of the enclosing div
         @keyword count_hit: if 1, add an event to the log
@@ -1020,8 +1019,6 @@
             media = 'screen'
         self.hilite_re = (keywords.get('hilite_re') or
                           request.form.get('highlight', [None])[0])
-        if msg is None:
-            msg = ""
 
         # count hit?
         if keywords.get('count_hit', 0):
@@ -1062,10 +1059,7 @@
         if 'deprecated' in pi:
             # deprecated page, append last backup version to current contents
             # (which should be a short reason why the page is deprecated)
-            msg = '%s<strong>%s</strong><br>%s' % (
-                self.formatter.smiley('/!\\'),
-                _('The backed up content of this page is deprecated and will not be included in search results!'),
-                msg)
+            request.theme.add_msg(_('The backed up content of this page is deprecated and will not be included in search results!'), "warning")
 
             revisions = self.getRevList()
             if len(revisions) >= 2: # XXX shouldn't that be ever the case!? Looks like not.
@@ -1105,24 +1099,22 @@
             # send the page header
             if self.default_formatter:
                 if self.rev:
-                    msg = "<strong>%s</strong><br>%s" % (
+                    request.theme.add_msg("<strong>%s</strong><br>%s" % (
                         _('Revision %(rev)d as of %(date)s') % {
                             'rev': self.rev,
                             'date': self.mtime_printable(request)
-                        }, msg)
+                        }, "info"))
 
                 # This redirect message is very annoying.
                 # Less annoying now without the warning sign.
                 if 'redirect' in request.form:
                     redir = request.form['redirect'][0]
-                    msg = '<strong>%s</strong><br>%s' % (
+                    request.theme.add_msg('<strong>%s</strong><br>%s' % (
                         _('Redirected from page "%(page)s"') % {'page':
-                            wikiutil.link_tag(request, wikiutil.quoteWikinameURL(redir) + "?action=show", self.formatter.text(redir))},
-                        msg)
+                            wikiutil.link_tag(request, wikiutil.quoteWikinameURL(redir) + "?action=show", self.formatter.text(redir))}), "info")
                 if 'redirect' in pi:
-                    msg = '<strong>%s</strong><br>%s' % (
-                        _('This page redirects to page "%(page)s"') % {'page': wikiutil.escape(pi['redirect'])},
-                        msg)
+                    request.theme.add_msg('<strong>%s</strong><br>%s' % (
+                        _('This page redirects to page "%(page)s"') % {'page': wikiutil.escape(pi['redirect'])}), "info")
 
                 # Page trail
                 trail = None
@@ -1132,7 +1124,7 @@
 
                 title = self.split_title()
 
-                request.theme.send_title(title, page=self, msg=msg,
+                request.theme.send_title(title, page=self,
                                     print_mode=print_mode,
                                     media=media, pi_refresh=pi.get('refresh'),
                                     allow_doubleclick=1, trail=trail,
--- a/MoinMoin/PageEditor.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/PageEditor.py	Sun Dec 23 23:52:43 2007 +0100
@@ -273,7 +273,7 @@
         if preview is not None:
             raw_body = self.get_raw_body()
             if use_draft:
-                request.write(_("[Content loaded from draft]"), '<br>')
+                request.theme.add_msg(_("[Content loaded from draft]"), 'info')
         elif self.exists():
             # If the page exists, we get the text from the page.
             # TODO: maybe warn if template argument was ignored because the page exists?
@@ -284,11 +284,11 @@
             if request.user.may.read(template_page):
                 raw_body = Page(request, template_page).get_raw_body()
                 if raw_body:
-                    request.write(_("[Content of new page loaded from %s]") % (template_page, ), '<br>')
+                    request.theme.add_msg(_("[Content of new page loaded from %s]") % (template_page, ), 'info')
                 else:
-                    request.write(_("[Template %s not found]") % (template_page, ), '<br>')
+                    request.theme.add_msg(_("[Template %s not found]") % (template_page, ), 'warning')
             else:
-                request.write(_("[You may not read %s]") % (template_page, ), '<br>')
+                request.theme.add_msg(_("[You may not read %s]") % (template_page, ), 'error')
 
         # Make backup on previews - but not for new empty pages
         if not use_draft and preview and raw_body:
@@ -311,11 +311,11 @@
         status = [msg for msg in status if msg]
         status = ' '.join(status)
         status = Status(request, content=status)
-
+        request.theme.add_msg(status, "dialog")
+        
         request.theme.send_title(
             title % {'pagename': self.split_title(), },
             page=self,
-            msg=status,
             html_head=self.lock.locktype and (
                 _countdown_js % {
                      'countdown_script': request.theme.externalScript('countdown'),
@@ -495,7 +495,8 @@
 
         backto = request.form.get('backto', [None])[0]
         page = backto and Page(request, backto) or self
-        page.send_page(msg=_('Edit was cancelled.'))
+        request.theme.add_msg(_('Edit was cancelled.', formatted=False), "error")
+        page.send_page()
 
     def copyPage(self, newpagename, comment=None):
         """ Copy the current version of the page (keeping the backups, logs and attachments).
--- a/MoinMoin/PageGraphicalEditor.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/PageGraphicalEditor.py	Sun Dec 23 23:52:43 2007 +0100
@@ -24,7 +24,8 @@
 def execute(pagename, request):
     if not request.user.may.write(pagename):
         _ = request.getText
-        Page(request, pagename).send_page(msg=_('You are not allowed to edit this page.'))
+        request.theme.add_msg_('You are not allowed to edit this page.', "error")
+        Page(request, pagename).send_page()
         return
 
     PageGraphicalEditor(request, pagename).sendEditor()
@@ -85,7 +86,8 @@
 
         # Did one of the prechecks fail?
         if msg:
-            self.send_page(msg=msg)
+            request.theme.add_msg(msg, "error")
+            self.send_page()
             return
 
         # check if we want to load a draft
--- a/MoinMoin/action/AttachFile.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/AttachFile.py	Sun Dec 23 23:52:43 2007 +0100
@@ -415,7 +415,8 @@
     return names #Returns dict of {origname: safename}
 
 def error_msg(pagename, request, msg):
-    Page(request, pagename).send_page(msg=msg)
+    request.theme.add_msg(msg, "error")
+    Page(request, pagename).send_page()
 
 
 #############################################################################
@@ -641,7 +642,8 @@
     request.emit_http_headers()
     # Use user interface language for this generated page
     request.setContentLanguage(request.lang)
-    request.theme.send_title(_('Attachments for "%(pagename)s"') % {'pagename': pagename}, pagename=pagename, msg=msg)
+    request.theme.add_msg(msg, "dialog")
+    request.theme.send_title(_('Attachments for "%(pagename)s"') % {'pagename': pagename}, pagename=pagename)
     request.write('<div id="content">\n') # start content div
     send_uploadform(pagename, request)
     request.write('</div>\n') # end content div
@@ -846,7 +848,8 @@
 </table>
 </form>''' % d
     thispage = Page(request, pagename)
-    return thispage.send_page(msg=formhtml)
+    request.theme.add_msg(formhtml, "dialog")
+    return thispage.send_page()
 
 def get_file(pagename, request):
     import shutil
--- a/MoinMoin/action/CopyPage.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/CopyPage.py	Sun Dec 23 23:52:43 2007 +0100
@@ -80,7 +80,7 @@
             self.request.http_redirect(url)
             self.request.finish()
         else:
-            self.render_msg(self.make_form())
+            self.render_msg(self.make_form(), "dialog")
 
     def get_form_html(self, buttons_html):
         _ = self._
--- a/MoinMoin/action/Despam.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/Despam.py	Sun Dec 23 23:52:43 2007 +0100
@@ -165,8 +165,8 @@
     actname = __name__.split('.')[-1]
     if actname in request.cfg.actions_excluded or \
        not request.user.isSuperUser():
-        return Page.Page(request, pagename).send_page(
-            msg=_('You are not allowed to use this action.'))
+        request.theme.add_msg(_('You are not allowed to use this action.'), "error")
+        return Page.Page(request, pagename).send_page()
 
     editor = request.form.get('editor', [None])[0]
     timestamp = time.time() - 24 * 3600
--- a/MoinMoin/action/LikePages.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/LikePages.py	Sun Dec 23 23:52:43 2007 +0100
@@ -24,20 +24,20 @@
 
     # Error?
     if isinstance(matches, (str, unicode)):
-        Page(request, pagename).send_page(msg=matches)
+        request.theme.add_msg(matches, "info")
+        Page(request, pagename).send_page()
         return
 
     # No matches
     if not matches:
-        Page(request, pagename).send_page(
-             msg=_('No pages like "%s"!') % (pagename, ))
+        request.theme.add_msg(_('No pages like "%s"!') % (pagename,), "error")
+        Page(request, pagename).send_page()
         return
 
     # One match - display it
     if len(matches) == 1:
-        Page(request, matches.keys()[0]).send_page(
-             msg=_('Exactly one page like "%s" found, redirecting to page.') % (
-            pagename, ))
+        request.theme.add_msg(_('Exactly one page like "%s" found, redirecting to page.', formatted=False) % (pagename,), "info")
+        Page(request, matches.keys()[0]).send_page()
         return
 
     # more than one match, list 'em
--- a/MoinMoin/action/Load.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/Load.py	Sun Dec 23 23:52:43 2007 +0100
@@ -105,7 +105,7 @@
             self.request.http_redirect(url)
             self.request.finish()
         else:
-            self.render_msg(self.make_form())
+            self.render_msg(self.make_form(), "dialog")
 
     def get_form_html(self, buttons_html):
         _ = self._
--- a/MoinMoin/action/MyPages.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/MyPages.py	Sun Dec 23 23:52:43 2007 +0100
@@ -19,7 +19,8 @@
         username = ''
 
     if not username:
-        return thispage.send_page(msg=_('Please log in first.'))
+        request.theme.add_msg(_('Please log in first.'), "error")
+        return thispage.send_page()
 
     userhomewiki = request.cfg.user_homewiki
     if userhomewiki != 'Self' and userhomewiki != request.cfg.interwikiname:
@@ -31,8 +32,8 @@
 
     homepage = Page(request, username)
     if not homepage.exists():
-        return homepage.send_page(
-            msg=_('Please first create a homepage before creating additional pages.'))
+        request.theme.add_msg(_('Please first create a homepage before creating additional pages.'), "error")
+        return homepage.send_page()
 
     pagecontent = _("""\
 You can add some additional sub pages to your already existing homepage here.
--- a/MoinMoin/action/PackagePages.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/PackagePages.py	Sun Dec 23 23:52:43 2007 +0100
@@ -51,13 +51,15 @@
 
         try:
             if not self.allowed():
-                raise ActionError(_('You are not allowed to edit this page.'))
+                self.request.theme.add_msg(_('You are not allowed to edit this page.'), "error")
+                raise ActionError
             elif not self.page.exists():
-                raise ActionError(_('This page is already deleted or was never created!'))
+                self.request.theme.add_msg(_('This page is already deleted or was never created!', formatted=False))
+                raise ActionError
 
             self.package()
         except ActionError, e:
-            return self.page.send_page(msg=e.args[0])
+            return self.page.send_page()
 
     def package(self):
         """ Packages pages. """
@@ -70,7 +72,8 @@
         packagename = form.get('packagename', [u''])[0]
 
         if not form.get('submit', [None])[0]:
-            raise ActionError(self.makeform())
+            self.request.theme.add_msg(self.makeform(), "dialog")
+            raise ActionError
 
         pages = []
         for pagename in unpackLine(pagelist, ","):
@@ -80,20 +83,23 @@
                 if page.exists() and self.request.user.may.read(pagename):
                     pages.append(page)
         if not pages:
-            raise ActionError(self.makeform(_('No pages like "%s"!') % wikiutil.escape(pagelist)))
+            self.request.theme.add_msg(self.makeform(_('No pages like "%s"!') % wikiutil.escape(pagelist)), "error")
+            raise ActionError
 
         pagelist = ', '.join([getattr(page, "page_name") for page in pages])
         target = wikiutil.taintfilename(packagename)
 
         if not target:
-            raise ActionError(self.makeform(_('Invalid filename "%s"!') % wikiutil.escape(packagename)))
+            self.request.theme.add_msg(self.makeform(_('Invalid filename "%s"!') % wikiutil.escape(packagename)), "error")
+            raise ActionError
 
         # get directory, and possibly create it
         attach_dir = Page(self.request, self.page.page_name).getPagePath("attachments", check_create=1)
         fpath = os.path.join(attach_dir, target).encode(config.charset)
         if os.path.exists(fpath):
-            raise ActionError(_("Attachment '%(target)s' (remote name '%(filename)s') already exists.") % {
-                'target': wikiutil.escape(target), 'filename': wikiutil.escape(target)})
+            self.request.theme.add_msg(_("Attachment '%(target)s' (remote name '%(filename)s') already exists.") % {
+                'target': wikiutil.escape(target), 'filename': wikiutil.escape(target)}, "error")
+            raise ActionError
 
         zf = zipfile.ZipFile(fpath, "w", COMPRESSION_LEVEL)
 
@@ -124,7 +130,8 @@
 
         _addLogEntry(self.request, 'ATTNEW', self.pagename, target)
 
-        raise ActionError(_("Created the package %s containing the pages %s.") % (wikiutil.escape(target), wikiutil.escape(pagelist)))
+        self.request.theme.add_msg(_("Created the package %s containing the pages %s.") % (wikiutil.escape(target), wikiutil.escape(pagelist)))
+        raise ActionError
 
     def makeform(self, error=""):
         """ Display a rename page form
--- a/MoinMoin/action/RenamePage.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/RenamePage.py	Sun Dec 23 23:52:43 2007 +0100
@@ -79,7 +79,7 @@
             self.request.http_redirect(url)
             self.request.finish()
         else:
-            self.render_msg(self.make_form())
+            self.render_msg(self.make_form(), "dialog")
 
     def get_form_html(self, buttons_html):
         _ = self._
--- a/MoinMoin/action/SpellCheck.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/SpellCheck.py	Sun Dec 23 23:52:43 2007 +0100
@@ -212,18 +212,19 @@
 
     page = Page(request, pagename)
     if not request.user.may.write(request.cfg.page_local_spelling_words):
-        msg = _("You can't save spelling words.")
-        page.send_page(msg=msg)
+        request.theme.add_msg(_("You can't save spelling words."), "error")
+        page.send_page()
         return
 
     if request.user.may.read(pagename):
         badwords, badwords_re, msg = checkSpelling(page, request)
     else:
         badwords = []
-        msg = _("You can't check spelling on a page you can't read.")
-
+        request.theme.add_msg(_("You can't check spelling on a page you can't read."), "error")
+    
+    request.theme.add_msg(msg, "dialog")
     if badwords:
-        page.send_page(msg=msg, hilite_re=badwords_re)
+        page.send_page(hilite_re=badwords_re)
     else:
-        page.send_page(msg=msg)
+        page.send_page()
 
--- a/MoinMoin/action/SubscribeUser.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/SubscribeUser.py	Sun Dec 23 23:52:43 2007 +0100
@@ -85,7 +85,8 @@
     _ = request.getText
     if not request.user.may.admin(pagename):
         thispage = Page(request, pagename)
-        return thispage.send_page(msg=_("You are not allowed to perform this action."))
+        request.theme.add_msg(_("You are not allowed to perform this action."), "error")
+        return thispage.send_page()
     elif 'users' not in request.form:
         show_form(pagename, request)
     else:
--- a/MoinMoin/action/SyncPages.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/SyncPages.py	Sun Dec 23 23:52:43 2007 +0100
@@ -160,7 +160,8 @@
 </div>
 </form>
 """ % d
-        self.page.send_page(msg=html_form)
+        self.request.theme.add_msg(html_form, "dialog")
+        self.page.send_page()
 
     def render(self):
         """ Render action
@@ -173,16 +174,16 @@
 
         try:
             if "cancel" in self.request.form:
-                raise ActionStatus(_("Operation was canceled."))
+                raise ActionStatus(_("Operation was canceled."), "error")
 
             if params["direction"] == UP:
-                raise ActionStatus(_("The only supported directions are BOTH and DOWN."))
+                raise ActionStatus(_("The only supported directions are BOTH and DOWN."), "error")
 
             if not self.request.cfg.interwikiname:
-                raise ActionStatus(_("Please set an interwikiname in your wikiconfig (see HelpOnConfiguration) to be able to use this action."))
+                raise ActionStatus(_("Please set an interwikiname in your wikiconfig (see HelpOnConfiguration) to be able to use this action."), "error")
 
             if not params["remoteWiki"]:
-                raise ActionStatus(_("Incorrect parameters. Please supply at least the ''remoteWiki'' parameter. Refer to HelpOnSynchronisation for help."))
+                raise ActionStatus(_("Incorrect parameters. Please supply at least the ''remoteWiki'' parameter. Refer to HelpOnSynchronisation for help."), "error")
 
             local = MoinLocalWiki(self.request, params["localPrefix"], params["pageList"])
             try:
@@ -191,12 +192,12 @@
                 raise ActionStatus(msg)
 
             if not remote.valid:
-                raise ActionStatus(_("The ''remoteWiki'' is unknown."))
+                raise ActionStatus(_("The ''remoteWiki'' is unknown."), "error")
             # if only the username is supplied, we ask for the password
             if params["user"] and not params["password"]:
                 return self.show_password_form()
         except ActionStatus, e:
-            msg = u'<p class="error">%s</p>\n' % (e.args[0], )
+            self.request.theme.add_msg(u'<p class="error">%s</p>\n' % (e.args[0], ), e.args[1])
         else:
             try:
                 try:
@@ -207,7 +208,7 @@
                     self.log_status(self.ERROR, _("A severe error occured:"), raw_suffix=temp_file.getvalue())
                     raise
                 else:
-                    msg = u"%s" % (_("Synchronisation finished. Look below for the status messages."), )
+                    self.request.theme.add_msg(u"%s" % (_("Synchronisation finished. Look below for the status messages."), ), "info")
             finally:
                 self.call_rollback_funcs()
                 # XXX aquire readlock on self.page
@@ -216,7 +217,7 @@
 
                 remote.delete_auth_token()
 
-        return self.page.send_page(msg=msg)
+        return self.page.send_page()
 
     def sync(self, params, local, remote):
         """ This method does the synchronisation work.
--- a/MoinMoin/action/__init__.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/__init__.py	Sun Dec 23 23:52:43 2007 +0100
@@ -150,13 +150,15 @@
 
         return Dialog(self.request, content=form_html)
 
-    def render_msg(self, msg):
+    def render_msg(self, msg, msgtype):
         """ Called to display some message (can also be the action form) """
-        self.page.send_page(msg=msg)
+        self.request.theme.add_msg(msg, msgtype)
+        self.page.send_page()
 
-    def render_success(self, msg):
+    def render_success(self, msg, msgtype):
         """ Called to display some message when the action succeeded """
-        self.page.send_page(msg=msg)
+        self.request.theme.add_msg(msg, msgtype)
+        self.page.send_page()
 
     def render_cancel(self):
         """ Called when user has hit the cancel button """
@@ -184,7 +186,7 @@
         if error is None:
             error = self.check_condition()
         if error:
-            self.render_msg(error)
+            self.render_msg(error, "error")
         elif self.form_trigger in form: # user hit the trigger button
             if self.ticket_ok():
                 success, self.error = self.do_action()
@@ -194,7 +196,7 @@
             self.do_action_finish(success)
         else:
             # Return a new form
-            self.render_msg(self.make_form())
+            self.render_msg(self.make_form(), "dialog")
 
     # Executing the action ---------------------------------------------------
     def do_action(self):
@@ -206,9 +208,9 @@
         """ Override this to handle success or failure (with error in self.error) of your action.
         """
         if success:
-            self.render_success(self.error)
+            self.render_success(self.error, "info")
         else:
-            self.render_msg(self.make_form()) # display the form again
+            self.render_msg(self.make_form(), "dialog") # display the form again
 
 
 # Builtin Actions ------------------------------------------------------------
--- a/MoinMoin/action/backup.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/backup.py	Sun Dec 23 23:52:43 2007 +0100
@@ -65,9 +65,9 @@
         dircount = len(dirs)
         return sendMsg(request, pagename,
             msg=_('Restored Backup: %(filename)s to target dir: %(targetdir)s.\nFiles: %(filecount)d, Directories: %(dircount)d') %
-                locals())
+                locals(), msgtype="info")
     except:
-        return sendMsg(request, pagename, msg=_("Restoring backup: %(filename)s to target dir: %(targetdir)s failed.") % locals())
+        return sendMsg(request, pagename, msg=_("Restoring backup: %(filename)s to target dir: %(targetdir)s failed.") % locals(), msgtype="info")
 
 def sendBackupForm(request, pagename):
     _ = request.getText
@@ -114,9 +114,10 @@
     request.theme.send_footer(pagename)
     request.theme.send_closing_html()
 
-def sendMsg(request, pagename, msg):
+def sendMsg(request, pagename, msg, msgtype):
     from MoinMoin import Page
-    return Page.Page(request, pagename).send_page(msg=msg)
+    request.theme.add_msg(msg, msgtype)
+    return Page.Page(request, pagename).send_page()
 
 def backupAllowed(request):
     """ Return True if backup is allowed """
@@ -129,7 +130,7 @@
     _ = request.getText
     if not backupAllowed(request):
         return sendMsg(request, pagename,
-                       msg=_('You are not allowed to do remote backup.'))
+                       msg=_('You are not allowed to do remote backup.'), msgtype="error")
 
     dowhat = request.form.get('do', [None])[0]
     if dowhat == 'backup':
@@ -140,4 +141,4 @@
         sendBackupForm(request, pagename)
     else:
         return sendMsg(request, pagename,
-                       msg=_('Unknown backup subaction: %s.') % dowhat)
+                       msg=_('Unknown backup subaction: %s.') % dowhat, msgtype="error")
--- a/MoinMoin/action/chart.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/chart.py	Sun Dec 23 23:52:43 2007 +0100
@@ -12,23 +12,23 @@
     """ Show page charts """
     _ = request.getText
     if not request.user.may.read(pagename):
-        msg = _("You are not allowed to view this page.")
-        return request.page.send_page(msg=msg)
+        request.theme.add_msg(_("You are not allowed to view this page."), "error")
+        return request.page.send_page()
 
     if not request.cfg.chart_options:
-        msg = _("Charts are not available!")
-        return request.page.send_page(msg=msg)
+        request.theme.add_msg(_("Charts are not available!"), "error")
+        return request.page.send_page()
 
     chart_type = request.form.get('type', [''])[0].strip()
     if not chart_type:
-        msg = _('You need to provide a chart type!')
-        return request.page.send_page(msg=msg)
+        request.theme.add_msg(_('You need to provide a chart type!'), "error")
+        return request.page.send_page()
 
     try:
         func = pysupport.importName("MoinMoin.stats.%s" % chart_type, 'draw')
     except (ImportError, AttributeError):
-        msg = _('Bad chart type "%s"!') % chart_type
-        return request.page.send_page(msg=msg)
+        request.theme.add_msg(_('Bad chart type "%s"!') % chart_type, "error")
+        return request.page.send_page()
 
     func(pagename, request)
 
--- a/MoinMoin/action/diff.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/diff.py	Sun Dec 23 23:52:43 2007 +0100
@@ -52,8 +52,8 @@
     currentpage = Page(request, pagename)
     currentrev = currentpage.current_rev()
     if currentrev < 2:
-        currentpage.send_page(msg=_("No older revisions available!"))
-        return
+        request.theme.add_msg(_("No older revisions available!"), "error")
+        currentpage.send_page()
 
     if date: # this is how we get called from RecentChanges
         rev1 = 0
--- a/MoinMoin/action/edit.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/edit.py	Sun Dec 23 23:52:43 2007 +0100
@@ -22,8 +22,8 @@
         return
 
     if not request.user.may.write(pagename):
-        Page(request, pagename).send_page(
-            msg=_('You are not allowed to edit this page.'))
+        request.theme.add_msg(_('You are not allowed to edit this page.'), "error")
+        Page(request, pagename).send_page()
         return
 
     valideditors = ['text', 'gui', ]
@@ -80,8 +80,8 @@
     if request.cfg.edit_ticketing:
         ticket = request.form.get('ticket', [''])[0]
         if not wikiutil.checkTicket(request, ticket):
-            msg = _('Please use the interactive user interface to use action %(actionname)s!') % {'actionname': 'edit' }
-            pg.send_page(msg=msg)
+            request.theme.add_msg(_('Please use the interactive user interface to use action %(actionname)s!') % {'actionname': 'edit' }, "error")
+            pg.send_page()
             return
 
     from MoinMoin.error import ConvertError
@@ -182,5 +182,5 @@
 
         # sets revision number to default for further actions
         request.rev = 0
-        pg.send_page(msg=savemsg)
-
+        request.theme.add_msg(savemsg, "info")
+        pg.send_page()
--- a/MoinMoin/action/fckdialog.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/fckdialog.py	Sun Dec 23 23:52:43 2007 +0100
@@ -539,5 +539,6 @@
         image_dialog(request)
     else:
         from MoinMoin.Page import Page
-        Page(request, pagename).send_page(msg="Dialog unknown!")
+        request.theme.add_msg("Dialog unknown!", "error")
+        Page(request, pagename).send_page()
 
--- a/MoinMoin/action/fullsearch.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/fullsearch.py	Sun Dec 23 23:52:43 2007 +0100
@@ -162,9 +162,9 @@
     # check for sensible search term
     stripped = needle.strip()
     if len(stripped) == 0:
-        err = _('Please use a more selective search term instead '
-                'of {{{"%s"}}}') % wikiutil.escape(needle)
-        Page(request, pagename).send_page(msg=err)
++        request.theme.add_msg(_('Please use a more selective search term instead '
++                'of {{{"%s"}}}') % wikiutil.escape(needle), "error")
++        Page(request, pagename).send_page()
         return
     needle = stripped
 
@@ -186,9 +186,9 @@
                 titlesearch=titlesearch).parse_query(needle)
         results = searchPages(request, query, sort, mtime, historysearch)
     except ValueError: # catch errors in the search query
-        err = _('Your search query {{{"%s"}}} is invalid. Please refer to '
-                'HelpOnSearching for more information.') % wikiutil.escape(needle)
-        Page(request, pagename).send_page(msg=err)
+        request.theme.add_msg(_('Your search query {{{"%s"}}} is invalid. Please refer to '
+                'HelpOnSearching for more information.') % wikiutil.escape(needle), "error")
+        Page(request, pagename).send_page()
         return
 
     # directly show a single hit
@@ -206,7 +206,7 @@
         querydict = wikiutil.parseQueryString(request.query_string)
         querydict.update({'titlesearch': 0})
 
-        err = _('Your search query {{{"%s"}}} didn\'t return any results. '
+        request.theme.add_msg(_('Your search query {{{"%s"}}} didn\'t return any results. '
                 'Please change some terms and refer to HelpOnSearching for '
                 'more information.%s') % (wikiutil.escape(needle),
                     titlesearch and ''.join([
@@ -216,8 +216,8 @@
                             escape=0, relative=False)),
                         _('full-text search with your search terms'),
                         f.url(0), '.',
-                    ]) or '')
-        Page(request, pagename).send_page(msg=err)
+                    ]) or ''), "error")
+        Page(request, pagename).send_page()
         return
 
     request.emit_http_headers()
--- a/MoinMoin/action/login.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/login.py	Sun Dec 23 23:52:43 2007 +0100
@@ -70,7 +70,8 @@
                     error.append('<p>')
                     error.append(msg)
                 error = ''.join(error)
-            return self.page.send_page(msg=error)
+            request.theme.add_msg(error, "error")
+            return self.page.send_page()
 
         else: # show login form
             request.emit_http_headers()
--- a/MoinMoin/action/logout.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/logout.py	Sun Dec 23 23:52:43 2007 +0100
@@ -26,8 +26,6 @@
         # but if the user manually added ?action=logout
         # and that isn't really supported, then don't
         if not self.request.user.valid:
-            message = _("You are now logged out.")
-        else:
-            message = None
-        return self.page.send_page(msg=message)
+            self.request.theme.add_msg(_("You are now logged out."), "info")
+        return self.page.send_page()
 
--- a/MoinMoin/action/newpage.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/newpage.py	Sun Dec 23 23:52:43 2007 +0100
@@ -73,7 +73,8 @@
         if error:
             # Send back to the page you came from, with an error msg
             page = Page(self.request, self.referrer)
-            page.send_page(msg=error)
+            request.theme.add_msg(error, "error")
+            page.send_page()
         else:
             # Redirect to new page using edit action. No error checking
             # is needed because it is done later in new request.
--- a/MoinMoin/action/quicklink.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/quicklink.py	Sun Dec 23 23:52:43 2007 +0100
@@ -11,20 +11,19 @@
 def execute(pagename, request):
     """ Add the current wiki page to the user quicklinks """
     _ = request.getText
-    msg = None
 
     if not request.user.valid:
-        msg = _("You must login to add a quicklink.")
+        request.theme.add_msg(_("You must login to add a quicklink."), "error")
     elif request.user.isQuickLinkedTo([pagename]):
         if request.user.removeQuicklink(pagename):
-            msg = _('Your quicklink to this page has been removed.')
+            request.theme.add_msg(_('Your quicklink to this page has been removed.'), "info")
         else: # should not happen
-            msg = _('Your quicklink to this page could not be removed.')
+            request.theme.add_msg(_('Your quicklink to this page could not be removed.'), "error")
     else:
         if request.user.addQuicklink(pagename):
-            msg = _('A quicklink to this page has been added for you.')
+            request.theme.add_msg(_('A quicklink to this page has been added for you.'), "info")
         else: # should not happen
-            msg = _('A quicklink to this page could not be added for you.')
+            request.theme.add_msg(_('A quicklink to this page could not be added for you.'), "error")
 
-    Page(request, pagename).send_page(msg=msg)
+    Page(request, pagename).send_page()
 
--- a/MoinMoin/action/revert.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/revert.py	Sun Dec 23 23:52:43 2007 +0100
@@ -20,4 +20,5 @@
         msg = unicode(error)
 
     request.reset()
-    pg.send_page(msg=msg)
+    request.theme.add_msg(msg, "dialog")
+    pg.send_page()
--- a/MoinMoin/action/subscribe.py	Sun Dec 23 23:51:55 2007 +0100
+++ b/MoinMoin/action/subscribe.py	Sun Dec 23 23:52:43 2007 +0100
@@ -12,38 +12,37 @@
     """ Subscribe or unsubscribe the user to pagename """
     _ = request.getText
     cfg = request.cfg
-    msg = None
 
     if not request.user.may.read(pagename):
-        msg = _("You are not allowed to subscribe to a page you can't read.")
+        request.theme.add_msg(_("You are not allowed to subscribe to a page you can't read."), "error")
 
     # Check if mail is enabled
     elif not cfg.mail_enabled and not cfg.jabber_enabled:
-        msg = _("This wiki is not enabled for mail/Jabber processing.")
+        request.theme.add_msg(_("This wiki is not enabled for mail/Jabber processing."), "error")
 
     # Suggest visitors to login
     elif not request.user.valid:
-        msg = _("You must log in to use subscriptions.")
+        request.theme.add_msg(_("You must log in to use subscriptions."), "error")
 
     # Suggest users without email to add their email address
     elif not request.user.email and not request.user.jid:
-        msg = _("Add your email address or Jabber ID in your UserPreferences to use subscriptions.")
+        request.theme.add_msg(_("Add your email address or Jabber ID in your UserPreferences to use subscriptions."), "error")
 
     elif request.user.isSubscribedTo([pagename]):
         # Try to unsubscribe
         if request.user.unsubscribe(pagename):
-            msg = _('Your subscription to this page has been removed.')
+            request.theme.add_msg(_('Your subscription to this page has been removed.'), "info")
         else:
-            msg = _("Can't remove regular expression subscription!") + u' ' + \
+            request.theme.add_msg(_("Can't remove regular expression subscription!") + u' ' + \
                   _("Edit the subscription regular expressions in your "
-                    "UserPreferences.")
+                    "UserPreferences."), "error")
 
     else:
         # Try to subscribe
         if request.user.subscribe(pagename):
-            msg = _('You have been subscribed to this page.')
+            request.theme.add_msg(_('You have been subscribed to this page.'), "info")
         else: # should not happen
-            msg = _('You could not get subscribed to this page.')
+            request.theme.add_msg(_('You could not get subscribed to this page.'), "error")
 
-    Page(request, pagename).send_page(msg=msg)
+    Page(request, pagename).send_page()