当前位置: 首页>>代码示例>>Python>>正文


Python Attachment.populate_from_attrs方法代码示例

本文整理汇总了Python中indico.modules.attachments.models.attachments.Attachment.populate_from_attrs方法的典型用法代码示例。如果您正苦于以下问题:Python Attachment.populate_from_attrs方法的具体用法?Python Attachment.populate_from_attrs怎么用?Python Attachment.populate_from_attrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在indico.modules.attachments.models.attachments.Attachment的用法示例。


在下文中一共展示了Attachment.populate_from_attrs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _clone_attachment_folder

# 需要导入模块: from indico.modules.attachments.models.attachments import Attachment [as 别名]
# 或者: from indico.modules.attachments.models.attachments.Attachment 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)
开发者ID:OmeGak,项目名称:indico,代码行数:16,代码来源:clone.py


注:本文中的indico.modules.attachments.models.attachments.Attachment.populate_from_attrs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。