changeset 4033:404220520c63

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 24 Aug 2008 18:03:16 +0200
parents 070d03f8fd7b (diff) 8a1c8fb7c689 (current diff)
children 8ced48dc0a3d
files MoinMoin/_tests/compat.py
diffstat 2 files changed, 19 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Aug 24 17:09:31 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Sun Aug 24 18:03:16 2008 +0200
@@ -591,11 +591,12 @@
                             # Load the module and set in sys.modules
                             module = imp.load_module(modname, fp, path, info)
                             setattr(sys.modules[self.siteid], 'csum', module)
-                            self._plugin_modules.append(modname)
                         finally:
                             # Make sure fp is closed properly
                             if fp:
                                 fp.close()
+                    if modname not in self._plugin_modules:
+                        self._plugin_modules.append(modname)
             finally:
                 imp.release_lock()
         except ImportError, err:
--- a/MoinMoin/wikiutil.py	Sun Aug 24 17:09:31 2008 +0200
+++ b/MoinMoin/wikiutil.py	Sun Aug 24 18:03:16 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