本文整理匯總了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)