Exemplo n.º 1
0
def create_cache(app, url):
    if isinstance(url, Cache):
        return url
    scheme, _, _ = parse_store_url(url)
    dotted_path = data_caches.get(scheme)
    if not dotted_path:
        raise ImproperlyConfigured('%s cache not available' % scheme)
    store_class = module_attribute(dotted_path)
    if not store_class:
        raise ImproperlyConfigured('"%s" store not available' % dotted_path)
    return store_class(app, scheme, url)
Exemplo n.º 2
0
def create_cache(app, url):
    if isinstance(url, Cache):
        return url
    scheme, _, _ = parse_store_url(url)
    dotted_path = data_caches.get(scheme)
    if not dotted_path:
        raise ImproperlyConfigured('%s cache not available' % scheme)
    store_class = module_attribute(dotted_path)
    if not store_class:
        raise ImproperlyConfigured('"%s" store not available' % dotted_path)
    return store_class(app, scheme, url)
Exemplo n.º 3
0
def search_engine(url, loop=None, **kw):
    if isinstance(url, SearchEngine):
        return url
    loop = loop or get_event_loop()
    if not loop:
        raise ImproperlyConfigured('no event loop')
    if isinstance(url, dict):
        extra = url.copy()
        url = extra.pop('url', None)
        extra.update(kw)
        kw = extra
    scheme, address, params = parse_store_url(url)
    dotted_path = search_engines.get(scheme)
    if not dotted_path:
        raise ImproperlyConfigured('%s search engine not available' % scheme)
    engine_class = module_attribute(dotted_path)
    params.update(kw)
    return engine_class(scheme, address, loop, **params)
Exemplo n.º 4
0
def search_engine(url, loop=None, **kw):
    if isinstance(url, SearchEngine):
        return url
    loop = loop or get_event_loop()
    if not loop:
        raise ImproperlyConfigured('no event loop')
    if isinstance(url, dict):
        extra = url.copy()
        url = extra.pop('url', None)
        extra.update(kw)
        kw = extra
    scheme, address, params = parse_store_url(url)
    dotted_path = search_engines.get(scheme)
    if not dotted_path:
        raise ImproperlyConfigured('%s search engine not available' % scheme)
    engine_class = module_attribute(dotted_path)
    params.update(kw)
    return engine_class(scheme, address, loop, **params)