Example #1
0
def get_enabled_plugins():
    """
    Open plugin config files from plugin_config_dir and determine if they are
    enabled.  If so, append them to 'enabled_plugins' in the root config.
    Uses the namespaces['root'].config dictionary.
    
    """
    config = get_config()
    if config.has_key('enabled_plugins'):
        enabled_plugins = config['enabled_plugins']
    else:
        enabled_plugins = []

    # determine enabled plugins

    # first from config files
    for _file in config['config_files']:
        try:
            cnf = ConfigObj(_file)
        except IOError, error:
            log.warning("Unable to open config '%s': %s" % \
                (_file, error.args[1]))
            continue

        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
Example #2
0
def get_enabled_plugins():
    """
    Open plugin config files from plugin_config_dir and determine if they are
    enabled.  If so, append them to 'enabled_plugins' in the root config.
    Uses the namespaces['root'].config dictionary.
    
    """
    config = get_config()
    if config.has_key('enabled_plugins'):
        enabled_plugins = config['enabled_plugins']
    else:
        enabled_plugins = []
        
    # determine enabled plugins
    
    # first from config files
    for _file in config['config_files']:    
        try:
            cnf = ConfigObj(_file)
        except IOError, error:
            log.warning("Unable to open config '%s': %s" % \
                (_file, error.args[1]))
            continue
            
        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
Example #3
0
    # Then for plugin config files
    for _file in os.listdir(config['plugin_config_dir']):
        path = os.path.join(config['plugin_config_dir'], _file)
        if not path.endswith('.conf'):
            continue

        cnf = ConfigObj(path)
        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
    return enabled_plugins


def load_plugin(plugin):
    """
    Load a cement plugin.  
    
    Required arguments:
    
        plugin
            Name of the plugin to load.  Should be accessible from the module
            path of 'myapp.plugin.myplugin'.
Example #4
0
    # Then for plugin config files
    for _file in os.listdir(config['plugin_config_dir']):
        path = os.path.join(config['plugin_config_dir'], _file)
        if not path.endswith('.conf'):
            continue
            
        cnf = ConfigObj(path)
        for sect in cnf.sections:
            if sect != 'root' and cnf[sect].has_key('enable_plugin') \
                              and t_f_pass(cnf[sect]['enable_plugin']) == True \
                              and not sect in enabled_plugins:
                if not cnf[sect].has_key('provider'):
                    provider = config['app_module']
                else:
                    provider = cnf[sect]['provider']
                    setup_logging_for_plugin_provider(provider)
                plugin = "%s.plugin.%s" % (provider, sect)
                if plugin not in enabled_plugins:
                    enabled_plugins.append(plugin)
    return enabled_plugins
    
def load_plugin(plugin):
    """
    Load a cement plugin.  
    
    Required arguments:
    
        plugin
            Name of the plugin to load.  Should be accessible from the module
            path of 'myapp.plugin.myplugin'.