當前位置: 首頁>>代碼示例>>Python>>正文


Python AttachmentFolder.populate_from_attrs方法代碼示例

本文整理匯總了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)
開發者ID:OmeGak,項目名稱:indico,代碼行數:16,代碼來源:clone.py


注:本文中的indico.modules.attachments.models.folders.AttachmentFolder.populate_from_attrs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。