當前位置: 首頁>>代碼示例>>Python>>正文


Python WorkspaceApi.get_all方法代碼示例

本文整理匯總了Python中tracim.lib.workspace.WorkspaceApi.get_all方法的典型用法代碼示例。如果您正苦於以下問題:Python WorkspaceApi.get_all方法的具體用法?Python WorkspaceApi.get_all怎麽用?Python WorkspaceApi.get_all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tracim.lib.workspace.WorkspaceApi的用法示例。


在下文中一共展示了WorkspaceApi.get_all方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_workspace_readable_calendars_for_user

# 需要導入模塊: from tracim.lib.workspace import WorkspaceApi [as 別名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_all [as 別名]
    def get_workspace_readable_calendars_for_user(cls, user: User)\
            -> ['Workspace']:
        workspaces = []
        workspace_api = WorkspaceApi(user)

        for workspace in workspace_api.get_all():
            if workspace.calendar_enabled:
                workspaces.append(workspace)

        return workspaces
開發者ID:buxx,項目名稱:tracim,代碼行數:12,代碼來源:calendar.py

示例2: index

# 需要導入模塊: from tracim.lib.workspace import WorkspaceApi [as 別名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_all [as 別名]
    def index(self):
        # NOTE BS 20161025: I can't use tmpl_context.current_user,
        # I d'ont know why
        workspace_api = WorkspaceApi(tmpl_context.identity.get('user'))
        workspaces = workspace_api.get_all()
        serialized_workspaces = Context(CTX.API_WORKSPACE).toDict(workspaces)

        return {
            'value_list': serialized_workspaces
        }
開發者ID:buxx,項目名稱:tracim,代碼行數:12,代碼來源:api.py

示例3: get_all

# 需要導入模塊: from tracim.lib.workspace import WorkspaceApi [as 別名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_all [as 別名]
    def get_all(self, *args, **kw):

        user = tmpl_context.current_user
        workspace_api_controller = WorkspaceApi(user)

        workspaces = workspace_api_controller.get_all()

        current_user_content = Context(CTX.CURRENT_USER).toDict(user)
        fake_api = Context(CTX.ADMIN_WORKSPACE).toDict({'current_user': current_user_content})

        dictified_workspaces = Context(CTX.ADMIN_WORKSPACES).toDict(workspaces, 'workspaces', 'workspace_nb')
        return DictLikeClass(result = dictified_workspaces, fake_api=fake_api)
開發者ID:Nonolost,項目名稱:tracim,代碼行數:14,代碼來源:workspace.py

示例4: Root

# 需要導入模塊: from tracim.lib.workspace import WorkspaceApi [as 別名]
# 或者: from tracim.lib.workspace.WorkspaceApi import get_all [as 別名]
class Root(DAVCollection):
    """
    Root ressource that represents tracim's home, which contains all workspaces
    """

    def __init__(self, path: str, environ: dict):
        super(Root, self).__init__(path, environ)

        self.user = UserApi(None).get_one_by_email(environ['http_authenticator.username'])
        # TODO BS 20170221: Web interface should list all workspace to. We
        # disable it here for moment. When web interface will be updated to
        # list all workspace, change this here to.
        self.workspace_api = WorkspaceApi(self.user, force_role=True)

    def __repr__(self) -> str:
        return '<DAVCollection: Root>'

    def getMemberNames(self) -> [str]:
        """
        This method returns the names (here workspace's labels) of all its children

        Though for perfomance issue, we're not using this function anymore
        """
        return [workspace.label for workspace in self.workspace_api.get_all()]

    def getMember(self, label: str) -> DAVCollection:
        """
        This method returns the child Workspace that corresponds to a given name

        Though for perfomance issue, we're not using this function anymore
        """
        try:
            workspace = self.workspace_api.get_one_by_label(label)
            workspace_path = '%s%s%s' % (self.path, '' if self.path == '/' else '/', transform_to_display(workspace.label))

            return Workspace(workspace_path, self.environ, workspace)
        except AttributeError:
            return None

    def createEmptyResource(self, name: str):
        """
        This method is called whenever the user wants to create a DAVNonCollection resource (files in our case).

        There we don't allow to create files at the root;
        only workspaces (thus collection) can be created.
        """
        raise DAVError(HTTP_FORBIDDEN)

    def createCollection(self, name: str):
        """
        This method is called whenever the user wants to create a DAVCollection resource as a child (in our case,
        we create workspaces as this is the root).

        [For now] we don't allow to create new workspaces through
        webdav client. Though if we come to allow it, deleting the error's raise will
        make it possible.
        """
        # TODO : remove comment here
        # raise DAVError(HTTP_FORBIDDEN)

        new_workspace = self.workspace_api.create_workspace(name)
        self.workspace_api.save(new_workspace)

        workspace_path = '%s%s%s' % (
        self.path, '' if self.path == '/' else '/', transform_to_display(new_workspace.label))

        transaction.commit()
        return Workspace(workspace_path, self.environ, new_workspace)

    def getMemberList(self):
        """
        This method is called by wsgidav when requesting with a depth > 0, it will return a list of _DAVResource
        of all its direct children
        """

        members = []
        for workspace in self.workspace_api.get_all():
            workspace_path = '%s%s%s' % (self.path, '' if self.path == '/' else '/', workspace.label)
            members.append(Workspace(workspace_path, self.environ, workspace))

        return members
開發者ID:lebouquetin,項目名稱:tracim,代碼行數:83,代碼來源:sql_resources.py


注:本文中的tracim.lib.workspace.WorkspaceApi.get_all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。