Esempio n. 1
0
def load_by_tags(tags):
    tags = set(tags)
    candids_all = set()
    for tag in tags:
        candids = DBResource.tags.filter(tag)
        candids_all.update(set(candids))
    return [Resource(r) for r in DBResource.multi_get(candids_all)]
Esempio n. 2
0
def load_by_tags(tags):
    tags = set(tags)
    candids_all = set()
    for tag in tags:
        candids = DBResource.tags.filter(tag)
        candids_all.update(set(candids))
    return [Resource(r) for r in DBResource.multi_get(candids_all)]
Esempio n. 3
0
def load_all(startswith=None):
    if startswith:
        start = startswith
        end = startswith + '~'
        candids = DBResource.bucket.get_index("$key", start, end).results
    else:
        candids = DBResource.updated.filter(StrInt.p_min(), StrInt.p_max())
    return [Resource(r) for r in DBResource.multi_get(candids)]
Esempio n. 4
0
def load_all(startswith=None):
    if startswith:
        start = startswith
        end = startswith + '~'
        candids = DBResource.bucket.get_index("$key", start, end).results
    else:
        candids = DBResource.updated.filter(StrInt.p_min(), StrInt.p_max())
    return [Resource(r) for r in DBResource.multi_get(candids)]
Esempio n. 5
0
def load_updated(since=None, with_childs=True):
    if since is None:
        startkey = StrInt.p_min()
    else:
        startkey = since
    candids = DBResource.updated.filter(startkey, StrInt.p_max())
    if with_childs:
        candids = DBResource.childs(candids)
    return [Resource(r) for r in DBResource.multi_get(candids)]
Esempio n. 6
0
def load_updated(since=None, with_childs=True):
    if since is None:
        startkey = StrInt.p_min()
    else:
        startkey = since
    candids = DBResource.updated.filter(startkey, StrInt.p_max())
    if with_childs:
        candids = DBResource.childs(candids)
    return [Resource(r) for r in DBResource.multi_get(candids)]
Esempio n. 7
0
def load_by_tags(query):
    if isinstance(query, (list, set, tuple)):
        query = '|'.join(query)

    parsed_tags = get_string_tokens(query)
    r_with_tags = [DBResource.tags.filter(tag) for tag in parsed_tags]
    r_with_tags = set(itertools.chain(*r_with_tags))
    resources = [Resource(r) for r in DBResource.multi_get(r_with_tags)]

    return filter(lambda n: Expression(query, n.tags).evaluate(), resources)
Esempio n. 8
0
def load_by_tags(query):
    if isinstance(query, (list, set, tuple)):
        query = '|'.join(query)

    parsed_tags = get_string_tokens(query)
    r_with_tags = [DBResource.tags.filter(tag) for tag in parsed_tags]
    r_with_tags = set(itertools.chain(*r_with_tags))
    resources = [Resource(r) for r in DBResource.multi_get(r_with_tags)]

    return filter(lambda n: Expression(query, n.tags).evaluate(), resources)
Esempio n. 9
0
def load_all():
    candids = DBResource.updated.filter(StrInt.p_min(), StrInt.p_max())
    return [Resource(r) for r in DBResource.multi_get(candids)]
Esempio n. 10
0
def load_by_names(names):
    return [Resource(r) for r in DBResource.multi_get(names)]
Esempio n. 11
0
def load_childs(parents):
    return [Resource(r) for r in
            DBResource.multi_get(DBResource.childs(parents))]
Esempio n. 12
0
def load_all():
    candids = DBResource.updated.filter(StrInt.p_min(), StrInt.p_max())
    return [Resource(r) for r in DBResource.multi_get(candids)]
Esempio n. 13
0
def load_by_names(names):
    return [Resource(r) for r in DBResource.multi_get(names)]
Esempio n. 14
0
def load_childs(parents):
    return [
        Resource(r) for r in DBResource.multi_get(DBResource.childs(parents))
    ]