本文整理汇总了Python中indico.modules.attachments.models.folders.AttachmentFolder.populate_from_attrs方法的典型用法代码示例。如果您正苦于以下问题:Python AttachmentFolder.populate_from_attrs方法的具体用法?Python AttachmentFolder.populate_from_attrs怎么用?Python AttachmentFolder.populate_from_attrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.attachments.models.folders.AttachmentFolder
的用法示例。
在下文中一共展示了AttachmentFolder.populate_from_attrs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _clone_attachment_folder
# 需要导入模块: from indico.modules.attachments.models.folders import AttachmentFolder [as 别名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import populate_from_attrs [as 别名]
def _clone_attachment_folder(self, old_folder, new_object):
folder_attrs = get_simple_column_attrs(AttachmentFolder) | {'acl'}
attachment_attrs = (get_simple_column_attrs(Attachment) | {'user', 'acl'}) - {'modified_dt'}
folder = AttachmentFolder(object=new_object)
folder.populate_from_attrs(old_folder, folder_attrs)
for old_attachment in old_folder.attachments:
attachment = Attachment(folder=folder)
attachment.populate_from_attrs(old_attachment, attachment_attrs)
if attachment.type == AttachmentType.file:
old_file = old_attachment.file
attachment.file = AttachmentFile(attachment=attachment, user=old_file.user, filename=old_file.filename,
content_type=old_file.content_type)
with old_file.open() as fd:
attachment.file.save(fd)