コード例 #1
0
ファイル: util.py プロジェクト: bkolobara/indico
def build_material_legacy_api_data(linked_object):
    # Skipping root folder and files in legacy API
    event = get_event(linked_object)
    try:
        cache = g.legacy_api_event_attachments[event]
    except (AttributeError, KeyError):
        if 'legacy_api_event_attachments' not in g:
            g.legacy_api_event_attachments = {}
        g.legacy_api_event_attachments[event] = cache = defaultdict(list)
        query = (event.all_attachment_folders
                 .filter_by(is_deleted=False, is_default=False)
                 .options(joinedload(AttachmentFolder.legacy_mapping), joinedload(AttachmentFolder.attachments)))
        for folder in query:
            cache[folder.object].append(folder)

    return filter(None, map(_build_folder_legacy_api_data, cache.get(linked_object, [])))
コード例 #2
0
ファイル: util.py プロジェクト: pmart123/indico
def build_material_legacy_api_data(linked_object):
    # Skipping root folder and files in legacy API
    event = get_event(linked_object)
    try:
        cache = g.legacy_api_event_attachments[event]
    except (AttributeError, KeyError):
        if 'legacy_api_event_attachments' not in g:
            g.legacy_api_event_attachments = {}
        g.legacy_api_event_attachments[event] = cache = defaultdict(list)
        query = (event.all_attachment_folders
                 .filter_by(is_deleted=False, is_default=False)
                 .options(joinedload(AttachmentFolder.legacy_mapping), joinedload(AttachmentFolder.attachments)))
        for folder in query:
            cache[folder.object].append(folder)

    return filter(None, map(_build_folder_legacy_api_data, cache.get(linked_object, [])))