本文整理汇总了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()