本文整理汇总了Python中indico.modules.attachments.models.folders.AttachmentFolder.get_for_linked_object方法的典型用法代码示例。如果您正苦于以下问题:Python AttachmentFolder.get_for_linked_object方法的具体用法?Python AttachmentFolder.get_for_linked_object怎么用?Python AttachmentFolder.get_for_linked_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.attachments.models.folders.AttachmentFolder
的用法示例。
在下文中一共展示了AttachmentFolder.get_for_linked_object方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _addMaterialFrom
# 需要导入模块: from indico.modules.attachments.models.folders import AttachmentFolder [as 别名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import get_for_linked_object [as 别名]
def _addMaterialFrom(self, target, categoryPath):
for folder in AttachmentFolder.get_for_linked_object(target, preload_event=True):
for attachment in folder.attachments:
if attachment.type == AttachmentType.file:
dst_path = posixpath.join(self._mainPath, "files", categoryPath,
"{}-{}".format(attachment.id, attachment.file.filename))
with attachment.file.get_local_path() as file_path:
self._addFileFromSrc(dst_path, file_path)
示例2: _add_material
# 需要导入模块: from indico.modules.attachments.models.folders import AttachmentFolder [as 别名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import get_for_linked_object [as 别名]
def _add_material(self, target, type_):
for folder in AttachmentFolder.get_for_linked_object(target, preload_event=True):
for attachment in folder.attachments:
if not attachment.can_access(None):
continue
if attachment.type == AttachmentType.file:
dst_path = posixpath.join(self._content_dir, "material", type_,
"{}-{}".format(attachment.id, attachment.file.filename))
with attachment.file.get_local_path() as file_path:
self._copy_file(dst_path, file_path)
示例3: get_attached_folders
# 需要导入模块: from indico.modules.attachments.models.folders import AttachmentFolder [as 别名]
# 或者: from indico.modules.attachments.models.folders.AttachmentFolder import get_for_linked_object [as 别名]
def get_attached_folders(linked_object, include_empty=True, include_hidden=True, preload_event=False):
"""
Return a list of all the folders linked to an object.
:param linked_object: The object whose attachments are to be returned
:param include_empty: Whether to return empty folders as well.
:param include_hidden: Include folders that the user can't see
:param preload_event: in the process, preload all objects tied to the
corresponding event and keep them in cache
"""
from indico.modules.attachments.models.folders import AttachmentFolder
folders = AttachmentFolder.get_for_linked_object(linked_object, preload_event=preload_event)
if not include_hidden:
folders = [f for f in folders if f.can_view(session.user)]
if not include_empty:
folders = [f for f in folders if f.attachments]
return folders