本文整理汇总了Python中mediadrop.model.meta.DBSession.expunge方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.expunge方法的具体用法?Python DBSession.expunge怎么用?Python DBSession.expunge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediadrop.model.meta.DBSession
的用法示例。
在下文中一共展示了DBSession.expunge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _delete_media
# 需要导入模块: from mediadrop.model.meta import DBSession [as 别名]
# 或者: from mediadrop.model.meta.DBSession import expunge [as 别名]
def _delete_media(self, media):
# FIXME: Ensure that if the first file is deleted from the file system,
# then the second fails, the first file is deleted from the
# file system and not linking to a nonexistent file.
# Delete every file from the storage engine
for file in media.files:
file.storage.delete(file.unique_id)
# Remove this item from the DBSession so that the foreign key
# ON DELETE CASCADE can take effect.
DBSession.expunge(file)
# Delete the media
DBSession.delete(media)
DBSession.flush()
# Cleanup the thumbnails
delete_thumbs(media)