当前位置: 首页>>代码示例>>Python>>正文


Python Entity.by_id方法代码示例

本文整理汇总了Python中aleph.model.Entity.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.by_id方法的具体用法?Python Entity.by_id怎么用?Python Entity.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aleph.model.Entity的用法示例。


在下文中一共展示了Entity.by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: merge

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def merge(id, other_id):
    entity = obj_or_404(Entity.by_id(id))
    check_authz(entity, authz.WRITE)
    other = obj_or_404(Entity.by_id(other_id))
    check_authz(other, authz.WRITE)
    entity.merge(other)
    db.session.commit()
    update_entity(entity)
    update_entity(other)
    return view(entity.id)
开发者ID:backgroundcheck,项目名称:aleph,代码行数:12,代码来源:entities_api.py

示例2: delete

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def delete(id):
    entity = obj_or_404(Entity.by_id(id))
    check_authz(entity, authz.WRITE)
    delete_entity(entity)
    db.session.commit()
    log_event(request, entity_id=entity.id)
    return jsonify({'status': 'ok'})
开发者ID:nivertech,项目名称:aleph,代码行数:9,代码来源:entities_api.py

示例3: delete

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def delete(id):
    entity = obj_or_404(Entity.by_id(id))
    check_authz(entity, authz.WRITE)
    entity.delete()
    db.session.commit()
    update_entity(entity)
    return jsonify({'status': 'ok'})
开发者ID:backgroundcheck,项目名称:aleph,代码行数:9,代码来源:entities_api.py

示例4: delete

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def delete(id):
    entity = obj_or_404(Entity.by_id(id))
    authz.require(authz.watchlist_write(entity.watchlist_id))
    entity.delete()
    db.session.commit()
    analyze_entity.delay(id)
    return jsonify({"status": "ok"})
开发者ID:DavidLemayian,项目名称:aleph,代码行数:9,代码来源:entities_api.py

示例5: delete

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def delete(id):
    entity = obj_or_404(Entity.by_id(id))
    authz.require(authz.collection_write(entity.collection_id))
    entity.delete()
    db.session.commit()
    analyze_entity.delay(id)
    return jsonify({'status': 'ok'})
开发者ID:stefanw,项目名称:aleph,代码行数:9,代码来源:entities_api.py

示例6: update

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def update(id):
    entity = obj_or_404(Entity.by_id(id))
    entity = Entity.save(get_data(entity=entity),
                         collection_id=entity.collection_id,
                         merge=arg_bool('merge'))
    db.session.commit()
    analyze_entity.delay(entity.id)
    return view(entity.id)
开发者ID:stefanw,项目名称:aleph,代码行数:10,代码来源:entities_api.py

示例7: delete

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def delete(id):
    entity = obj_or_404(Entity.by_id(id))
    authz.require(authz.list_write(entity.list_id))
    selectors = entity.terms
    entity.delete()
    db.session.commit()
    refresh_selectors.delay(list(selectors))
    return jsonify({"status": "ok"})
开发者ID:nightsh,项目名称:aleph,代码行数:10,代码来源:entities_api.py

示例8: analyze_entity

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def analyze_entity(entity_id):
    seen = set()
    query = {'term': {'entities.entity_id': entity_id}}
    for doc_id in query_doc_ids(query):
        analyze_document.delay(doc_id)
        seen.add(doc_id)
    entity = Entity.by_id(entity_id)
    if entity is not None:
        analyze_terms(entity.terms, seen=seen)
开发者ID:stefanw,项目名称:aleph,代码行数:11,代码来源:__init__.py

示例9: update

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def update(id):
    entity = obj_or_404(Entity.by_id(id))
    authz.require(authz.watchlist_write(entity.watchlist_id))
    data = EntityForm().deserialize(request_data())
    watchlist = data.get("watchlist")
    authz.require(watchlist)
    authz.require(authz.watchlist_write(watchlist.id))
    entity.update(data)
    watchlist.touch()
    db.session.commit()
    analyze_entity.delay(entity.id)
    return view(entity.id)
开发者ID:DavidLemayian,项目名称:aleph,代码行数:14,代码来源:entities_api.py

示例10: update

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def update(id):
    entity = obj_or_404(Entity.by_id(id))
    authz.require(authz.list_write(entity.list_id))
    data = EntityForm().deserialize(request_data())
    authz.require(data["list"])
    authz.require(authz.list_write(data["list"].id))
    old_selectors = entity.terms
    entity.update(data)
    db.session.commit()
    selectors = old_selectors.symmetric_difference(entity.terms)
    refresh_selectors.delay(list(selectors))
    return view(entity.id)
开发者ID:nightsh,项目名称:aleph,代码行数:14,代码来源:entities_api.py

示例11: update

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def update(id):
    entity = obj_or_404(Entity.by_id(id))
    authz.require(authz.collection_write(entity.collection_id))
    data = request_data()
    collection = data.get('collection')
    authz.require(collection)
    authz.require(authz.collection_write(collection.id))
    entity.update(data)
    collection.touch()
    db.session.commit()
    analyze_entity.delay(entity.id)
    return view(entity.id)
开发者ID:01-,项目名称:aleph,代码行数:14,代码来源:entities_api.py

示例12: update

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def update(id):
    entity = obj_or_404(Entity.by_id(id))
    check_authz(entity, authz.WRITE)
    data = request_data()
    data['id'] = entity.id
    possible_collections = authz.collections(authz.WRITE)
    possible_collections.extend([c.id for c in entity.collections])
    data['collections'] = [c for c in get_collections(data)
                           if c.id in possible_collections]
    entity = Entity.save(data, merge=arg_bool('merge'))
    db.session.commit()
    update_entity(entity)
    return view(entity.id)
开发者ID:backgroundcheck,项目名称:aleph,代码行数:15,代码来源:entities_api.py

示例13: update

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def update(id):
    entity = obj_or_404(Entity.by_id(id))
    check_authz(entity, authz.WRITE)
    data = request_data()
    data["id"] = entity.id
    possible_collections = authz.collections(authz.WRITE)
    possible_collections.extend([c.id for c in entity.collections])
    collections = [c for c in get_collections(data) if c.id in possible_collections]
    try:
        entity = Entity.save(data, collections, merge=arg_bool("merge"))
    except ValueError as ve:
        raise BadRequest(ve.message)
    for collection in entity.collections:
        collection.touch()
    db.session.commit()
    log_event(request, entity_id=entity.id)
    update_entity(entity)
    return view(entity.id)
开发者ID:CodeForAfrica,项目名称:aleph,代码行数:20,代码来源:entities_api.py

示例14: generate_graph

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def generate_graph(args):
    fields = ['id', 'collection', 'entities.uuid', 'entities.name',
              'entities.$schema']
    query = documents_query(args, fields=fields, facets=False)
    query = {'query': query['query']}

    graph = nx.MultiGraph()
    for doc in scan_iter(query):
        entities = set()
        for entity in doc.get('_source').get('entities', []):
            if not graph.has_node(entity.get('uuid')):
                obj = Entity.by_id(entity.get('uuid'))
                graph.add_node(entity.get('uuid'),
                               label=obj.name,
                               schema=obj.type)
            entities.add(entity.get('uuid'))
        for (src, dst) in combinations(entities, 2):
            graph.add_edge(src, dst, weight=1)
    graph = multigraph_to_weighted(graph)
    return paginate_graph(graph)
开发者ID:backgroundcheck,项目名称:aleph,代码行数:22,代码来源:graph_api.py

示例15: view

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import by_id [as 别名]
def view(id):
    entity = obj_or_404(Entity.by_id(id))
    authz.require(authz.watchlist_read(entity.watchlist_id))
    return jsonify(entity)
开发者ID:DavidLemayian,项目名称:aleph,代码行数:6,代码来源:entities_api.py


注:本文中的aleph.model.Entity.by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。