changeset 2417:b114a130c659

Merge main.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Tue, 17 Jul 2007 19:09:10 +0200
parents bf9fb139b5d3 (current diff) 878cc77c74ea (diff)
children 78d745b57730
files MoinMoin/xmlrpc/__init__.py
diffstat 5 files changed, 51 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Tue Jul 17 03:37:38 2007 +0200
+++ b/MoinMoin/config/multiconfig.py	Tue Jul 17 19:09:10 2007 +0200
@@ -205,6 +205,9 @@
 class DefaultConfig:
     """ default config values """
 
+    # internal dict for plugin `modules' lists
+    _site_plugin_lists = {}
+
     # setting DesktopEdition = True gives all local users special powers - ONLY use for MMDE style usage!
     DesktopEdition = False
 
--- a/MoinMoin/failure.py	Tue Jul 17 03:37:38 2007 +0200
+++ b/MoinMoin/failure.py	Tue Jul 17 19:09:10 2007 +0200
@@ -9,6 +9,8 @@
 import sys, os, logging
 
 from MoinMoin.support import cgitb
+from MoinMoin.error import ConfigurationError
+from traceback import extract_tb
 
 
 class View(cgitb.View):
@@ -61,20 +63,31 @@
     def formatMessage(self):
         """ handle multiple paragraphs messages and add general help """
         f = self.formatter
-        text = [self.formatExceptionMessage(self.info),
+        text = [self.formatExceptionMessage(self.info)]
+
+        if self.info[0] == ConfigurationError:
+            tbt = extract_tb(self.info[1].exceptions()[-1][2])[-1]
+            text.append(
+                f.paragraph('Error in your configuration file "%s"'
+                            ' around line %d.' % tbt[:2]))
+        else:
+            text.append(
                 f.paragraph("If you want to report a bug, please save "
-                            "this page and  attach it to your bug report."), ]
+                            "this page and  attach it to your bug report."))
         return ''.join(text)
 
     def formatButtons(self):
         """ Add 'buttons' to the error dialog """
         f = self.formatter
         buttons = [f.link('javascript:toggleDebugInfo()',
-                          'Show debugging information'),
+                          'Show debugging information')]
+        if self.info[0] != ConfigurationError:
+            buttons.append(
                    f.link('http://moinmoin.wikiwikiweb.de/MoinMoinBugs',
-                          'Report bug'),
+                          'Report bug'))
+            buttons.append(
                    f.link('http://moinmoin.wikiwikiweb.de/FrontPage',
-                          'Visit MoinMoin wiki'), ]
+                          'Visit MoinMoin wiki'))
         return f.list(buttons, {'class': 'buttons'})
 
     def formatDebugInfo(self):
@@ -143,9 +156,14 @@
     logging.error('%s: %s' % (err.__class__.__name__, str(err)), exc_info=savedError)
     try:
         debug = 'debug' in getattr(request, 'form', {})
-        handler = cgitb.Hook(file=request,
-                             display=request.cfg.traceback_show,
-                             logdir=request.cfg.traceback_log_dir,
+        # default to True here to allow an admin setting up the wiki
+        # to see the errors made in the configuration file
+        display = True
+        logdir = None
+        if hasattr(request, 'cfg'):
+            display = request.cfg.traceback_show
+            logdir = request.cfg.traceback_log_dir
+        handler = cgitb.Hook(file=request, display=display, logdir=logdir,
                              viewClass=View, debug=debug)
         handler.handle()
     except:
--- a/MoinMoin/userprefs/oid.py	Tue Jul 17 03:37:38 2007 +0200
+++ b/MoinMoin/userprefs/oid.py	Tue Jul 17 19:09:10 2007 +0200
@@ -29,14 +29,14 @@
         self._ = request.getText
         self.cfg = request.cfg
         self.title = self._("OpenID settings")
-
-    def allowed(self):
-        if _openid_disabled:
-            return False
-        for authm in self.request.cfg.auth:
-            if isinstance(authm, OpenIDAuth):
-                return UserPrefBase.allowed(self)
-        return False
+        openid_auth = False
+        if not _openid_disabled:
+            for authm in self.request.cfg.auth:
+                if isinstance(authm, OpenIDAuth):
+                    openid_auth = True
+                    break
+        if not openid_auth:
+            self.allowed = lambda: False
 
     def _handle_remove(self):
         _ = self.request.getText
--- a/MoinMoin/wikiutil.py	Tue Jul 17 03:37:38 2007 +0200
+++ b/MoinMoin/wikiutil.py	Tue Jul 17 19:09:10 2007 +0200
@@ -1090,16 +1090,25 @@
 def wikiPlugins(kind, cfg):
     """ Gets a list of modules in data/plugin/'kind'
 
-    Require valid plugin directory. e.g missing 'parser' directory or
-    missing '__init__.py' file will raise errors.
-
     @param kind: what kind of modules we look for
     @rtype: list
     @return: module names
     """
     # Wiki plugins are located in wikiconfig.plugin module
     modulename = '%s.plugin.%s' % (cfg.siteid, kind)
-    return pysupport.importName(modulename, "modules")
+
+    # short-cut if we've loaded the list already
+    # (or already failed to load it)
+    if kind in cfg._site_plugin_lists:
+        return cfg._site_plugin_lists[kind]
+
+    try:
+        plugins = pysupport.importName(modulename, "modules")
+        cfg._site_plugin_lists[kind] = plugins
+        return plugins
+    except ImportError:
+        cfg._site_plugin_lists[kind] = []
+        return []
 
 
 def getPlugins(kind, cfg):
--- a/MoinMoin/xmlrpc/__init__.py	Tue Jul 17 03:37:38 2007 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Tue Jul 17 19:09:10 2007 +0200
@@ -593,7 +593,7 @@
 
     # authorization methods
 
-    def _cleanup_stale_tokens(request):
+    def _cleanup_stale_tokens(self, request):
         items = caching.get_cache_list(request, 'xmlrpc-session', 'farm')
         tnow = time.time()
         for item in items: