Exemple #1
0
def pluginFromDict(config, interface):
    """
    Instantiates a plugin from the given config dict
    The section must have a "plugin" option
    """
    plugin_name = config['plugin']

    if ':' in plugin_name:
        module_name, object_name = plugin_name.split(":", 1)
        plugin = load_plugin(module_name, object_name=object_name)
        return plugin(config)

    plugin = load_plugin(plugin_name, interface)
    return plugin(config)
Exemple #2
0
 def test_load_module(self):
     p = load_plugin("lwr.plugins.dummy", EventStore)
     self.assertTrue(issubclass(p, EventStore))
Exemple #3
0
 def test_load_file_byname(self):
     p = load_plugin(os.path.join(os.path.dirname(__file__), "../plugins/dummy/store.py"), object_name="DummyEventStore")
     self.assertTrue(issubclass(p, EventStore))
Exemple #4
0
 def test_load_module_byname(self):
     p = load_plugin("lwr.plugins.dummy", object_name="DummyEventStore")
     self.assertTrue(issubclass(p, EventStore))
Exemple #5
0
 def test_load_file_notfound(self):
     with self.assertRaises(ImportError):
         load_plugin(os.path.join(os.path.dirname(__file__), "../plugins/dummy/XXX.py"), EventStore)
Exemple #6
0
 def test_load_module_notfound(self):
     with self.assertRaises(ImportError):
         load_plugin("lwr.plugins.XXX", EventStore)