本文整理汇总了Python中indico.modules.attachments.models.attachments.Attachment.populate_from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Attachment.populate_from_dict方法的具体用法?Python Attachment.populate_from_dict怎么用?Python Attachment.populate_from_dict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.attachments.models.attachments.Attachment
的用法示例。
在下文中一共展示了Attachment.populate_from_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_attachment_link
# 需要导入模块: from indico.modules.attachments.models.attachments import Attachment [as 别名]
# 或者: from indico.modules.attachments.models.attachments.Attachment import populate_from_dict [as 别名]
def add_attachment_link(data, linked_object):
"""Add a link attachment to linked_object"""
folder = data.pop('folder', None)
if not folder:
folder = AttachmentFolder.get_or_create_default(linked_object=linked_object)
assert folder.object == linked_object
link = Attachment(user=session.user, type=AttachmentType.link, folder=folder)
link.populate_from_dict(data, skip={'acl', 'protected'})
if link.is_self_protected:
link.acl = data['acl']
db.session.flush()
logger.info('Attachment %s added by %s', link, session.user)
signals.attachments.attachment_created.send(link, user=session.user)