本文整理汇总了Python中osf.models.BaseFileNode.remove_one方法的典型用法代码示例。如果您正苦于以下问题:Python BaseFileNode.remove_one方法的具体用法?Python BaseFileNode.remove_one怎么用?Python BaseFileNode.remove_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf.models.BaseFileNode
的用法示例。
在下文中一共展示了BaseFileNode.remove_one方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addon_delete_file_node
# 需要导入模块: from osf.models import BaseFileNode [as 别名]
# 或者: from osf.models.BaseFileNode import remove_one [as 别名]
def addon_delete_file_node(self, node, user, event_type, payload):
""" Get addon BaseFileNode(s), move it into the TrashedFileNode collection
and remove it from StoredFileNode.
Required so that the guids of deleted addon files are not re-pointed when an
addon file or folder is moved or renamed.
"""
if event_type == 'file_removed' and payload.get('provider', None) != 'osfstorage':
provider = payload['provider']
path = payload['metadata']['path']
materialized_path = payload['metadata']['materialized']
if path.endswith('/'):
folder_children = BaseFileNode.resolve_class(provider, BaseFileNode.ANY).objects.filter(
provider=provider,
node=node,
_materialized_path__startswith=materialized_path
)
for item in folder_children:
if item.kind == 'file' and not TrashedFileNode.load(item._id):
item.delete(user=user)
elif item.kind == 'folder':
BaseFileNode.remove_one(item)
else:
try:
file_node = BaseFileNode.resolve_class(provider, BaseFileNode.FILE).objects.get(
node=node,
_materialized_path=materialized_path
)
except BaseFileNode.DoesNotExist:
file_node = None
if file_node and not TrashedFileNode.load(file_node._id):
file_node.delete(user=user)