Beispiel #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)]
Beispiel #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)]
Beispiel #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)]
Beispiel #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)]
Beispiel #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)]
Beispiel #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)]
Beispiel #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)
Beispiel #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)
Beispiel #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)]
Beispiel #10
0
def load_by_names(names):
    return [Resource(r) for r in DBResource.multi_get(names)]
Beispiel #11
0
def load_childs(parents):
    return [Resource(r) for r in
            DBResource.multi_get(DBResource.childs(parents))]
Beispiel #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)]
Beispiel #13
0
def load_by_names(names):
    return [Resource(r) for r in DBResource.multi_get(names)]
Beispiel #14
0
def load_childs(parents):
    return [
        Resource(r) for r in DBResource.multi_get(DBResource.childs(parents))
    ]