entities.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:query-srv 作者: openpermissions 项目源码 文件源码
def get_entity(repository_id, entity_type, entity_id):
    """
    Get an entity from a repository

    :param repository_id: the repository that contains the entity
    :param entity_type: a valid entity type (asset, offer or agreement)
    :param entity_id: the entity's ID
    :returns: the entity data from the repository service
    :raises: tornado.httpclient.HTTPError
    """
    endpoint = yield entity_endpoint(repository_id, entity_type)
    if not endpoint:
        raise Return(None)

    try:
        result = yield endpoint[entity_id].get()
    except httpclient.HTTPError as err:
        if err.code == 404:
            raise Return(None)
        else:
            raise

    raise Return(result['data'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号