diff MoinMoin/wikiutil.py @ 1520:563bfe02b04f

Removed a lot of ugly MimeType() calls, refactored it into a helper, fixed page rendering for missing parsers.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sun, 03 Sep 2006 01:06:20 +0200
parents a796d366f176
children e36313297589
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Sun Sep 03 00:34:29 2006 +0200
+++ b/MoinMoin/wikiutil.py	Sun Sep 03 01:06:20 2006 +0200
@@ -1114,6 +1114,25 @@
     return all_plugins
 
 
+def searchAndImportPlugin(cfg, type, name, what=None):
+    type2classname = {"parser": "Parser",
+                      "formatter": "Formatter",
+    }
+    if what is None:
+        what = type2classname[type]
+    mt = MimeType(name)
+    plugin = None
+    for module_name in mt.module_name():
+        try:
+            plugin = importPlugin(cfg, type, module_name, what)
+            break
+        except PluginMissingError:
+            pass
+    else:
+        raise PluginMissingError("Plugin not found!")
+    return plugin
+
+
 #############################################################################
 ### Parsers
 #############################################################################