changeset 4032:070d03f8fd7b

plugin loader: minor cleanups
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 24 Aug 2008 18:02:28 +0200
parents 68951e8e069d
children 404220520c63
files MoinMoin/wikiutil.py
diffstat 1 files changed, 17 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Sun Aug 24 17:53:55 2008 +0200
+++ b/MoinMoin/wikiutil.py	Sun Aug 24 18:02:28 2008 +0200
@@ -1128,7 +1128,7 @@
     See importPlugin docstring.
     """
     if not name in builtinPlugins(kind):
-        raise PluginMissingError
+        raise PluginMissingError()
     moduleName = 'MoinMoin.%s.%s' % (kind, name)
     return importNameFromPlugin(moduleName, function)
 
@@ -1180,24 +1180,22 @@
     """
     # short-cut if we've loaded the dict already
     # (or already failed to load it)
-    if kind in cfg._site_plugin_lists:
-        return cfg._site_plugin_lists[kind]
-
-    result = {}
-
-    for modname in cfg._plugin_modules:
-        try:
-            module = pysupport.importName(modname, kind)
-            packagepath = os.path.dirname(module.__file__)
-            plugins = pysupport.getPluginModules(packagepath)
-
-            for p in plugins:
-                if not p in result:
-                    result[p] = '%s.%s' % (modname, kind)
-        except AttributeError:
-            pass
-
-    cfg._site_plugin_lists[kind] = result
+    cache = cfg._site_plugin_lists
+    if kind in cache:
+        result = cache[kind]
+    else:
+        result = {}
+        for modname in cfg._plugin_modules:
+            try:
+                module = pysupport.importName(modname, kind)
+                packagepath = os.path.dirname(module.__file__)
+                plugins = pysupport.getPluginModules(packagepath)
+                for p in plugins:
+                    if not p in result:
+                        result[p] = '%s.%s' % (modname, kind)
+            except AttributeError:
+                pass
+        cache[kind] = result
     return result