Exemple #1
0
def create_manager(config):
    """
    Will create a component manager from the specified
    configuration by looking for keys starting with 'qtools.components.*'.
    The rest of the name will be the key in the manager, and the value
    will be the class specified by the value (which should be an absolute
    path to the class).

    Right now, values are intended to be classes only, though this could
    be refined to register_class, register_method and register_module,
    to swap in different functions and modules at runtime.
    """
    module_dict = dict()
    for k, v in config.items():
        if k.startswith('qtools.components.'):
            component_name = k.split('.')[-1]
            # assume here that paths fully qualified
            module_name = ('.').join(v.split('.')[:-1])
            class_name = v.split('.')[-1]
            # absolute import (level = 0)
            module = __import__(module_name, globals(), locals(), [class_name], 0)
            module_dict[component_name] = getattr(module, class_name)
            module_dict['pylons_config'] = config
    
    return ComponentManager(module_dict)
Exemple #2
0
def get_common_map_config():
    '''
        Returns a dict with all configuration options related to the common
        base map (ie those starting with 'ckanext.spatial.common_map.')
    '''
    namespace = 'ckanext.spatial.common_map.'
    return dict([(k.replace(namespace, ''), v) for k, v in config.items() if k.startswith(namespace)])
Exemple #3
0
def get_oauth_config(provider):
    key = 'oauth.' + provider + '.'
    keylen = len(key)
    d = {}
    for k, v in config.items():
        if k.startswith(key):
            d[k[keylen:]] = v
    return d
Exemple #4
0
def get_oauth_config(provider):
    key = 'oauth.'+provider+'.'
    keylen = len(key)
    d = {}
    for k,v in config.items():
        if k.startswith(key):
            d[k[keylen:]] = v
    return d
Exemple #5
0
def get_section_from_config(config, section):
    items = config.items(section)
    tmp = dict()
    
    for item in items:
        tmp[item[0]] = item[1]
    
    return tmp
Exemple #6
0
def get_ofs():
    storage_backend = config['ofs.impl']
    kw = {}
    for k,v in config.items():
        if not k.startswith('ofs.') or k == 'ofs.impl':
            continue
        kw[k[4:]] = v
    ofs = get_impl(storage_backend)(**kw)
    return ofs
Exemple #7
0
def get_ofs():
    """Return a configured instance of the appropriate OFS driver.
    """
    storage_backend = config['ofs.impl']
    kw = {}
    for k,v in config.items():
        if not k.startswith('ofs.') or k == 'ofs.impl':
            continue
        kw[k[4:]] = v
    ofs = get_impl(storage_backend)(**kw)
    return ofs
def get_ofs():
    """Return a configured instance of the appropriate OFS driver.
    """
    storage_backend = config['ofs.impl']
    kw = {}
    for k, v in config.items():
        if not k.startswith('ofs.') or k == 'ofs.impl':
            continue
        kw[k[4:]] = v
    ofs = get_impl(storage_backend)(**kw)
    return ofs
Exemple #9
0
def get_ofs():
    """Return a configured instance of the appropriate OFS driver.
    """
    storage_backend = config["ofs.impl"]
    kw = {}
    for k, v in config.items():
        if not k.startswith("ofs.") or k == "ofs.impl":
            continue
        kw[k[4:]] = v

    # Make sure we have created the marker file to avoid pairtree issues
    if storage_backend == "pairtree" and "storage_dir" in kw:
        create_pairtree_marker(kw["storage_dir"])

    ofs = get_impl(storage_backend)(**kw)
    return ofs
Exemple #10
0
def get_ofs():
    """Return a configured instance of the appropriate OFS driver.
    """
    storage_backend = config['ofs.impl']
    kw = {}
    for k, v in config.items():
        if not k.startswith('ofs.') or k == 'ofs.impl':
            continue
        kw[k[4:]] = v

    # Make sure we have created the marker file to avoid pairtree issues
    if storage_backend == 'pairtree' and 'storage_dir' in kw:
        create_pairtree_marker(kw['storage_dir'])

    ofs = get_impl(storage_backend)(**kw)
    return ofs