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


Python Content.format_path方法代码示例

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


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

示例1: serialize_node_for_page

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import format_path [as 别名]
def serialize_node_for_page(content: Content, context: Context):

    if content.type in (ContentType.Page, ContentType.File) :
        data_container = content

        # The following properties are overriden by revision values
        if content.revision_to_serialize>0:
            for revision in content.revisions:
                if revision.revision_id==content.revision_to_serialize:
                    data_container = revision
                    break

        result = DictLikeClass(
            id=content.content_id,
            parent=context.toDict(content.parent),
            workspace=context.toDict(content.workspace),
            type=content.type,
            is_new=content.has_new_information_for(context.get_user()),
            content=data_container.description,
            created=data_container.created,
            updated=content.last_revision.updated,
            label=data_container.label,
            icon=ContentType.get_icon(content.type),
            owner=context.toDict(content.first_revision.owner),
            last_modification_author=context.toDict(content.last_revision.owner),
            status=context.toDict(data_container.get_status()),
            links=[],
            revision_nb = len(content.revisions),
            selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
            history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history()),
            is_editable=content.is_editable,
            is_deleted=content.is_deleted,
            is_archived=content.is_archived,
            urls = context.toDict({
                'mark_read': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_read', content)),
                'mark_unread': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_unread', content))
            })
        )

        if content.type == ContentType.File:
            depot = DepotManager.get()
            depot_stored_file = depot.get(data_container.depot_file)
            result.label = content.label
            result['file'] = DictLikeClass(
                name=data_container.file_name,
                size=depot_stored_file.content_length,
                mimetype=data_container.file_mimetype)
        return result

    if content.type==ContentType.Folder:
        value = DictLikeClass(
            id=content.content_id,
            label=content.label,
            is_new=content.has_new_information_for(context.get_user()),
        )
        return value

    raise NotImplementedError
开发者ID:lebouquetin,项目名称:tracim,代码行数:60,代码来源:serializers.py

示例2: serialize_node_for_page

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import format_path [as 别名]
def serialize_node_for_page(content: Content, context: Context):

    if content.type in (ContentType.Page, ContentType.File) :
        data_container = content

        # The following properties are overriden by revision values
        if content.revision_to_serialize>0:
            for revision in content.revisions:
                if revision.revision_id==content.revision_to_serialize:
                    data_container = revision
                    break

        result = DictLikeClass(
            id=content.content_id,
            parent=context.toDict(content.parent),
            workspace=context.toDict(content.workspace),
            type=content.type,
            is_new=content.has_new_information_for(context.get_user()),
            content=data_container.description,
            created=data_container.created,
            label=data_container.label,
            icon=ContentType.get_icon(content.type),
            owner=context.toDict(data_container.owner),
            status=context.toDict(data_container.get_status()),
            links=context.toDict(content.extract_links_from_content(data_container.description)),
            revisions=context.toDict(sorted(content.revisions, key=lambda v: v.created, reverse=True)),
            selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
            history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history()),
            urls = context.toDict({
                'mark_read': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_read', content)),
                'mark_unread': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_unread', content))
            })
        )

        if content.type==ContentType.File:
            result.label = content.label if content.label else content.file_name
            result['file'] = DictLikeClass(
                name = data_container.file_name,
                size = len(data_container.file_content),
                mimetype = data_container.file_mimetype)
        return result

    if content.type==ContentType.Folder:
        value = DictLikeClass(
            id=content.content_id,
            label=content.label,
            is_new=content.has_new_information_for(context.get_user()),
        )
        return value

    raise NotImplementedError
开发者ID:DarkDare,项目名称:tracim,代码行数:53,代码来源:serializers.py

示例3: serialize_node_for_thread

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import format_path [as 别名]
def serialize_node_for_thread(item: Content, context: Context):
    if item.type in (ContentType.Thread, ContentType.Task, ContentType.Ticket):
        return DictLikeClass(
            content = item.description,
            created = item.created,
            updated = item.last_revision.updated,
            revision_nb = len(item.revisions),
            icon = ContentType.get_icon(item.type),
            id = item.content_id,
            label = item.label,
            links=[],
            owner = context.toDict(item.owner),
            last_modification_author=context.toDict(item.last_revision.owner),
            parent = context.toDict(item.parent),
            selected_revision = 'latest',
            status = context.toDict(item.get_status()),
            type = item.type,
            workspace = context.toDict(item.workspace),
            comments = reversed(context.toDict(item.get_comments())),
            is_new=item.has_new_information_for(context.get_user()),
            history = Context(CTX.CONTENT_HISTORY).toDict(item.get_history()),
            is_editable=item.is_editable,
            is_deleted=item.is_deleted,
            is_archived=item.is_archived,
            urls = context.toDict({
                'mark_read': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_read', item)),
                'mark_unread': context.url(Content.format_path('/workspaces/{wid}/folders/{fid}/{ctype}s/{cid}/put_unread', item))
            }),
        )

    if item.type == ContentType.Comment:
        return DictLikeClass(
            is_new=item.has_new_information_for(context.get_user()),
            content = item.description,
            created = item.created,
            created_as_delta = item.created_as_delta(),
            icon = ContentType.get_icon(item.type),
            id = item.content_id,
            label = item.label,
            owner = context.toDict(item.owner),
            # REMOVE parent = context.toDict(item.parent),
            type = item.type,
            urls = context.toDict({
                'delete': context.url('/workspaces/{wid}/folders/{fid}/{ctype}/{cid}/comments/{commentid}/put_delete'.format(wid = item.workspace_id, fid=item.parent.parent_id, ctype=item.parent.type+'s', cid=item.parent.content_id, commentid=item.content_id))
            })
        )

    if item.type==ContentType.Folder:
        return Context(CTX.DEFAULT).toDict(item)
开发者ID:lebouquetin,项目名称:tracim,代码行数:51,代码来源:serializers.py


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