本文整理汇总了Python中website.files.models.FileNode.load方法的典型用法代码示例。如果您正苦于以下问题:Python FileNode.load方法的具体用法?Python FileNode.load怎么用?Python FileNode.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类website.files.models.FileNode
的用法示例。
在下文中一共展示了FileNode.load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_file_guid_referent
# 需要导入模块: from website.files.models import FileNode [as 别名]
# 或者: from website.files.models.FileNode import load [as 别名]
def update_file_guid_referent(self, node, event_type, payload, user=None):
if event_type == 'addon_file_moved' or event_type == 'addon_file_renamed':
source = payload['source']
destination = payload['destination']
source_node = Node.load(source['node']['_id'])
destination_node = node
file_guids = FileNode.resolve_class(source['provider'], FileNode.ANY).get_file_guids(
materialized_path=source['materialized'] if source['provider'] != 'osfstorage' else source['path'],
provider=source['provider'],
node=source_node)
if event_type == 'addon_file_renamed' and source['provider'] in settings.ADDONS_BASED_ON_IDS:
return
if event_type == 'addon_file_moved' and (source['provider'] == destination['provider'] and
source['provider'] in settings.ADDONS_BASED_ON_IDS) and source_node == destination_node:
return
for guid in file_guids:
obj = Guid.load(guid)
if source_node != destination_node and Comment.find(Q('root_target', 'eq', guid)).count() != 0:
update_comment_node(guid, source_node, destination_node)
if source['provider'] != destination['provider'] or source['provider'] != 'osfstorage':
old_file = FileNode.load(obj.referent._id)
obj.referent = create_new_file(obj, source, destination, destination_node)
obj.save()
if old_file and not TrashedFileNode.load(old_file._id):
old_file.delete()
示例2: update_comment_root_target_file
# 需要导入模块: from website.files.models import FileNode [as 别名]
# 或者: from website.files.models.FileNode import load [as 别名]
def update_comment_root_target_file(self, node, event_type, payload, user=None):
if event_type == 'addon_file_moved':
source = payload['source']
destination = payload['destination']
source_node = Node.load(source['node']['_id'])
destination_node = node
if (source.get('provider') == destination.get('provider') == 'osfstorage') and source_node._id != destination_node._id:
obj = FileNode.load(source.get('path').strip('/'))
update_folder_contents([obj], source_node, destination_node)
示例3: migrate_file_representation
# 需要导入模块: from website.files.models import FileNode [as 别名]
# 或者: from website.files.models.FileNode import load [as 别名]
def migrate_file_representation(bad_file):
logger.info('Migrating file representation of File: {0}'.format(bad_file))
view_url = bad_file['viewUrl'].rstrip('/')
fid = view_url.split('/')[-1]
fnode = FileNode.load(fid)
if fnode is None:
fnode = TrashedFileNode.load(fid)
assert fnode is not None, 'Could not load FileNode or TrashedFileNode with id {}'.format(fid)
data = {
'data': {
'kind': 'file',
'name': bad_file['selectedFileName'],
'path': fnode.path,
'extra': {},
'sha256': fnode.versions[-1].metadata['sha256']
}
}
bad_file.update(data)
示例4: update_comment_root_target_file
# 需要导入模块: from website.files.models import FileNode [as 别名]
# 或者: from website.files.models.FileNode import load [as 别名]
def update_comment_root_target_file(self, node, event_type, payload, user=None):
if event_type == 'addon_file_moved':
source = payload['source']
destination = payload['destination']
source_node = Node.load(source['node']['_id'])
destination_node = node
if (source.get('provider') == destination.get('provider') == 'osfstorage') and source_node._id != destination_node._id:
old_file = FileNode.load(source.get('path').strip('/'))
new_file = FileNode.resolve_class(destination.get('provider'), FileNode.FILE).get_or_create(destination_node, destination.get('path'))
Comment.update(Q('root_target', 'eq', old_file._id), data={'node': destination_node})
# update node record of commented files
if old_file._id in source_node.commented_files:
destination_node.commented_files[new_file._id] = source_node.commented_files[old_file._id]
del source_node.commented_files[old_file._id]
source_node.save()
destination_node.save()
示例5: view_file
# 需要导入模块: from website.files.models import FileNode [as 别名]
# 或者: from website.files.models.FileNode import load [as 别名]
def view_file(request, node_id, provider, file_id):
file = FileNode.load(file_id)
wb_url = file.generate_waterbutler_url()
return redirect(wb_url)