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


Python ContentApi.get_all方法代码示例

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


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

示例1: workspace_content

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_all [as 别名]
 def workspace_content(
         self,
         context,
         request: TracimRequest,
         hapic_data=None,
 ) -> typing.List[ContentInContext]:
     """
     return a list of contents of the space.
     This is NOT the full content list: by default, returned contents are the ones at root level.
     In order to get contents in a given folder, then use parent_id query filter.
     You can also show.hide archived/deleted contents.
     """
     app_config = request.registry.settings['CFG']
     content_filter = hapic_data.query
     api = ContentApi(
         current_user=request.current_user,
         session=request.dbsession,
         config=app_config,
         show_archived=content_filter.show_archived,
         show_deleted=content_filter.show_deleted,
         show_active=content_filter.show_active,
     )
     contents = api.get_all(
         parent_ids=content_filter.parent_ids,
         complete_path_to_id=content_filter.complete_path_to_id,
         workspace=request.current_workspace,
         content_type=content_filter.content_type or content_type_list.Any_SLUG,
         label=content_filter.label,
         order_by_properties=[Content.label]
     )
     contents = [
         api.get_content_in_context(content) for content in contents
     ]
     return contents
开发者ID:tracim,项目名称:tracim,代码行数:36,代码来源:workspace_controller.py

示例2: getMemberList

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_all [as 别名]
    def getMemberList(self) -> [_DAVResource]:
        members = []
        content_api = ContentApi(
            current_user=self.user,
            config=self.provider.app_config,
            session=self.session,
        )
        visible_children = content_api.get_all(
            [self.content.content_id],
            content_type_list.Any_SLUG,
            self.workspace,
        )

        for content in visible_children:
            content_path = '%s/%s' % (self.path, webdav_convert_file_name_to_display(content.file_name))

            try:
                if content.type == content_type_list.Folder.slug:
                    members.append(
                        FolderResource(
                            path=content_path,
                            environ=self.environ,
                            workspace=self.workspace,
                            content=content,
                            tracim_context=self.tracim_context
                        )
                    )
                elif content.type == content_type_list.File.slug:
                    self._file_count += 1
                    members.append(
                        FileResource(
                            path=content_path,
                            environ=self.environ,
                            content=content,
                            tracim_context=self.tracim_context
                        ))
                else:
                    self._file_count += 1
                    members.append(
                        OtherFileResource(
                            path=content_path,
                            environ=self.environ,
                            content=content,
                            tracim_context=self.tracim_context
                        ))
            except NotImplementedError as exc:
                pass

        return members
开发者ID:tracim,项目名称:tracim,代码行数:51,代码来源:resources.py

示例3: WorkspaceResource

# 需要导入模块: from tracim_backend.lib.core.content import ContentApi [as 别名]
# 或者: from tracim_backend.lib.core.content.ContentApi import get_all [as 别名]
class WorkspaceResource(DAVCollection):
    """
    Workspace resource corresponding to tracim's workspaces.
    Direct children can only be folders, though files might come later on and are supported
    """

    def __init__(self,
                 path: str,
                 environ: dict,
                 workspace: Workspace,
                 tracim_context: 'WebdavTracimContext'
    ) -> None:
        super(WorkspaceResource, self).__init__(path, environ)

        self.workspace = workspace
        self.content = None
        self.tracim_context = tracim_context
        self.user = tracim_context.current_user
        self.session = tracim_context.dbsession
        self.content_api = ContentApi(
            current_user=self.user,
            session=tracim_context.dbsession,
            config=tracim_context.app_config,
            show_temporary=True
        )

        self._file_count = 0

    def __repr__(self) -> str:
        return "<DAVCollection: Workspace (%d)>" % self.workspace.workspace_id


    def getPreferredPath(self):
        return self.path

    def getCreationDate(self) -> float:
        return mktime(self.workspace.created.timetuple())

    def getDisplayName(self) -> str:
        return webdav_convert_file_name_to_display(self.workspace.label)

    def getDisplayInfo(self):
        return {
            'type': "workspace".capitalize(),
        }

    def getLastModified(self) -> float:
        return mktime(self.workspace.updated.timetuple())

    def getMemberNames(self) -> [str]:
        retlist = []

        children = self.content_api.get_all(
            parent_ids=[self.content.id] if self.content is not None else None,
            workspace=self.workspace
        )

        for content in children:
            # the purpose is to display .history only if there's at least one content's type that has a history
            if content.type != content_type_list.Folder.slug:
                self._file_count += 1
            retlist.append(webdav_convert_file_name_to_display(content.file_name))

        return retlist

    def getMember(self, content_label: str) -> _DAVResource:

        return self.provider.getResourceInst(
            '%s/%s' % (self.path, webdav_convert_file_name_to_display(content_label)),
            self.environ
        )

    @webdav_check_right(is_contributor)
    def createEmptyResource(self, file_name: str):
        """
        [For now] we don't allow to create files right under workspaces.
        Though if we come to allow it, deleting the error's raise will make it possible.
        """
        # TODO : remove commentary here raise DAVError(HTTP_FORBIDDEN)
        if '/.deleted/' in self.path or '/.archived/' in self.path:
            raise DAVError(HTTP_FORBIDDEN)

        content = None

        # Note: To prevent bugs, check here again if resource already exist
        # fixed path
        fixed_file_name = webdav_convert_file_name_to_display(file_name)
        path = os.path.join(self.path, file_name)
        resource = self.provider.getResourceInst(path, self.environ)
        if resource:
            content = resource.content

        # return item
        return FakeFileStream(
            session=self.session,
            file_name=fixed_file_name,
            content_api=self.content_api,
            workspace=self.workspace,
            content=content,
            parent=self.content,
#.........这里部分代码省略.........
开发者ID:tracim,项目名称:tracim,代码行数:103,代码来源:resources.py


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