comparison MoinMoin/wikiutil.py @ 2381:b8b87daf7cc4

don't require all plugins to be in the data/plugin dir, cache modules list
author Johannes Berg <johannes AT sipsolutions DOT net>
date Tue, 17 Jul 2007 13:23:10 +0200
parents a7f4b02f5fdb
children 45641cbe7729
comparison
equal deleted inserted replaced
2380:0d04c8c82eb6 2381:b8b87daf7cc4
1088 1088
1089 1089
1090 def wikiPlugins(kind, cfg): 1090 def wikiPlugins(kind, cfg):
1091 """ Gets a list of modules in data/plugin/'kind' 1091 """ Gets a list of modules in data/plugin/'kind'
1092 1092
1093 Require valid plugin directory. e.g missing 'parser' directory or
1094 missing '__init__.py' file will raise errors.
1095
1096 @param kind: what kind of modules we look for 1093 @param kind: what kind of modules we look for
1097 @rtype: list 1094 @rtype: list
1098 @return: module names 1095 @return: module names
1099 """ 1096 """
1100 # Wiki plugins are located in wikiconfig.plugin module 1097 # Wiki plugins are located in wikiconfig.plugin module
1101 modulename = '%s.plugin.%s' % (cfg.siteid, kind) 1098 modulename = '%s.plugin.%s' % (cfg.siteid, kind)
1102 return pysupport.importName(modulename, "modules") 1099
1100 # short-cut if we've loaded the list already
1101 # (or already failed to load it)
1102 if kind in cfg._site_plugin_lists:
1103 return cfg._site_plugin_lists[kind]
1104
1105 try:
1106 plugins = pysupport.importName(modulename, "modules")
1107 cfg._site_plugin_lists[kind] = plugins
1108 return plugins
1109 except ImportError:
1110 cfg._site_plugin_lists[kind] = []
1111 return []
1103 1112
1104 1113
1105 def getPlugins(kind, cfg): 1114 def getPlugins(kind, cfg):
1106 """ Gets a list of plugin names of kind 1115 """ Gets a list of plugin names of kind
1107 1116