changeset 3622:29ae93c888f2

fix PageList macro with search errors
author Johannes Berg <johannes AT sipsolutions DOT net>
date Mon, 19 May 2008 16:44:53 +0200
parents c0d6bc8f7c29
children c02522af6533
files MoinMoin/macro/PageList.py
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/PageList.py	Mon May 19 13:58:19 2008 +0200
+++ b/MoinMoin/macro/PageList.py	Mon May 19 16:44:53 2008 +0200
@@ -26,6 +26,16 @@
         return '<span class="error">%s</span>' % err
 
     # Return a title search for needle, sorted by name.
-    results = search.searchPages(macro.request, needle,
-              titlesearch=1, case=case, sort='page_name')
-    return results.pageList(macro.request, macro.formatter, paging=False)
+    try:
+        results = search.searchPages(macro.request, needle,
+                                     titlesearch=1, case=case,
+                                     sort='page_name')
+        ret = results.pageList(macro.request, macro.formatter, paging=False)
+    except ValueError:
+        # same error as in MoinMoin/action/fullsearch.py, keep it that way!
+        ret = ''.join([macro.formatter.text('<<PageList('),
+                      _('Your search query {{{"%s"}}} is invalid. Please refer to '
+                        'HelpOnSearching for more information.', wiki=True,
+                        percent=True) % wikiutil.escape(needle),
+                      macro.formatter.text(')>>')])
+    return ret