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


Python ContentApi.get_one_revision方法代码示例

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


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

示例1: exists

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_one_revision [as 别名]
    def exists(self, path, environ) -> bool:
        """
        Called by wsgidav to check if a certain path is linked to a _DAVResource
        """

        tracim_context = environ['tracim_context']
        tracim_context.set_path(path)
        path = normpath(path)
        working_path = tracim_context.reduce_path(path)
        root_path = environ['http_authenticator.realm']
        parent_path = dirname(working_path)
        user = tracim_context.current_user
        session = tracim_context.dbsession
        if path == root_path:
            return True

        try:
            workspace = tracim_context.current_workspace
        except WorkspaceNotFound:
            workspace = None

        if parent_path == root_path or workspace is None:
            return workspace is not None

        # TODO bastien: Arnaud avait mis a True, verif le comportement
        # lorsque l'on explore les dossiers archive et deleted
        content_api = ContentApi(
            current_user=user,
            session=session,
            config=self.app_config,
            show_archived=False,
            show_deleted=False
        )

        revision_id = re.search(r'/\.history/[^/]+/\((\d+) - [a-zA-Z]+\) ([^/].+)$', path)

        is_archived = self.is_path_archive(path)

        is_deleted = self.is_path_delete(path)

        if revision_id:
            revision_id = revision_id.group(1)
            content = content_api.get_one_revision(revision_id)
        else:
            try:
                content = tracim_context.current_content
            except ContentNotFound:
                content = None

        return content is not None \
            and content.is_deleted == is_deleted \
            and content.is_archived == is_archived
开发者ID:tracim,项目名称:tracim,代码行数:54,代码来源:dav_provider.py

示例2: download_revisions_file

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_one_revision [as 别名]
    def download_revisions_file(self, context, request: TracimRequest, hapic_data=None):  # nopep8
        """
        Download raw file for specific revision of content.
        Good pratice for filename is filename is `{label}_r{revision_id}{file_extension}`.
        Default filename value is 'raw' (without file extension) or nothing.
        """
        app_config = request.registry.settings['CFG']
        api = ContentApi(
            show_archived=True,
            show_deleted=True,
            current_user=request.current_user,
            session=request.dbsession,
            config=app_config,
        )
        content = api.get_one(
            hapic_data.path.content_id,
            content_type=content_type_list.Any_SLUG
        )
        revision = api.get_one_revision(
            revision_id=hapic_data.path.revision_id,
            content=content
        )
        try:
            file = DepotManager.get().get(revision.depot_file)
        except IOError as exc:
            raise TracimFileNotFound(
                'file related to revision {} of content {} not found in depot.'.format(
                    revision.revision_id,
                    revision.content_id
                )
            ) from exc

        filename = hapic_data.path.filename
        if not filename or filename == 'raw':
            filename = "{label}_r{revision_id}{file_extension}".format(
                label=revision.file_name,
                revision_id=revision.revision_id,
                file_extension=revision.file_extension
            )
        return HapicFile(
            file_object=file,
            mimetype=file.content_type,
            filename=filename,
            as_attachment=hapic_data.query.force_download
        )
开发者ID:tracim,项目名称:tracim,代码行数:47,代码来源:file_controller.py

示例3: sized_preview_jpg_revision

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_one_revision [as 别名]
 def sized_preview_jpg_revision(self, context, request: TracimRequest, hapic_data=None):  # nopep8
     """
     Obtain resized jpg preview of a specific revision of content.
     Good pratice for filename is filename is `{label}_r{revision_id}_page_{page_number}_{width}x{height}.jpg`.
     Default filename value is 'raw' (without file extension) or nothing.
     """
     app_config = request.registry.settings['CFG']
     api = ContentApi(
         show_archived=True,
         show_deleted=True,
         current_user=request.current_user,
         session=request.dbsession,
         config=app_config,
     )
     content = api.get_one(
         hapic_data.path.content_id,
         content_type=content_type_list.Any_SLUG
     )
     revision = api.get_one_revision(
         revision_id=hapic_data.path.revision_id,
         content=content
     )
     jpg_preview_path = api.get_jpg_preview_path(
         content_id=content.content_id,
         revision_id=revision.revision_id,
         page_number=hapic_data.query.page,
         height=hapic_data.path.height,
         width=hapic_data.path.width,
         file_extension=revision.file_extension,
     )
     filename = hapic_data.path.filename
     if not filename or filename == 'raw':
         filename = "{label}_r{revision_id}_page_{page_number}_{width}x{height}.jpg".format(  # nopep8
             revision_id=revision.revision_id,
             label=revision.label,
             page_number=hapic_data.query.page,
             width=hapic_data.path.width,
             height=hapic_data.path.height
         )
     return HapicFile(
         file_path=jpg_preview_path,
         filename=filename,
         as_attachment=hapic_data.query.force_download
     )
开发者ID:tracim,项目名称:tracim,代码行数:46,代码来源:file_controller.py

示例4: preview_pdf_revision

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_one_revision [as 别名]
 def preview_pdf_revision(self, context, request: TracimRequest, hapic_data=None):  # nopep8
     """
     Obtain a specific page pdf preview of a specific revision of content.
     Good pratice for filename is filename is `{label}_page_{page_number}.pdf`.
     Default filename value is 'raw' (without file extension) or nothing.
     """
     app_config = request.registry.settings['CFG']
     api = ContentApi(
         show_archived=True,
         show_deleted=True,
         current_user=request.current_user,
         session=request.dbsession,
         config=app_config,
     )
     content = api.get_one(
         hapic_data.path.content_id,
         content_type=content_type_list.Any_SLUG
     )
     revision = api.get_one_revision(
         revision_id=hapic_data.path.revision_id,
         content=content
     )
     pdf_preview_path = api.get_pdf_preview_path(
         revision.content_id,
         revision.revision_id,
         page_number=hapic_data.query.page,
         file_extension=revision.file_extension,
     )
     filename = hapic_data.path.filename
     if not filename or filename == 'raw':
         filename = "{label}_page_{page_number}.pdf".format(
             label=content.label,
             page_number=hapic_data.query.page
         )
     return HapicFile(
         file_path=pdf_preview_path,
         filename=filename,
         as_attachment=hapic_data.query.force_download
     )
开发者ID:tracim,项目名称:tracim,代码行数:41,代码来源:file_controller.py


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