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


Python Entity.delete_by_collection方法代码示例

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


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

示例1: delete_collection_content

# 需要导入模块: from aleph.model import Entity [as 别名]
# 或者: from aleph.model.Entity import delete_by_collection [as 别名]
def delete_collection_content(collection_id):
    # Deleting a collection affects many associated objects and requires
    # checks, so this is done manually and in detail here.
    q = db.session.query(Collection)
    q = q.filter(Collection.id == collection_id)
    collection = q.first()
    if collection is None:
        log.error("No collection with ID: %r", collection_id)
        return

    log.info("Deleting collection [%r]: %r", collection.id, collection.label)
    deleted_at = collection.deleted_at or datetime.utcnow()
    Entity.delete_by_collection(collection_id, deleted_at=deleted_at)
    Match.delete_by_collection(collection_id, deleted_at=deleted_at)
    Permission.delete_by_collection(collection_id, deleted_at=deleted_at)
    index.delete_collection(collection_id)
    index.delete_entities(collection_id)
    collection.delete(deleted_at=deleted_at)
    db.session.commit()
开发者ID:pudo,项目名称:aleph,代码行数:21,代码来源:collections.py


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