コード例 #1
0
    def update(self):
        context = self.context
        request = self.request

        wfactories = []
        for name, factory in getAdapters((context,), IWorkspaceFactory):
            if not IInactiveWorkspaceFactory.providedBy(factory) and \
                    not context.isEnabled(factory) or \
                    not checkPermission('zope.View', factory.get()):
                continue
            wfactories.append((
                    factory.weight, factory.title, name, factory))

        wfactories.sort()
        if self.workspaces:
            wfactories = [(n, f) for _w, _t, n, f in wfactories \
                              if n in self.workspaces]
        else:
            wfactories = [(n, f) for _w, _t, n, f in wfactories]

        workspaces = []
        for name, factory in wfactories:
            workspaces.append(
                 {'name': name,
                  'title': factory.title,
                  'description': factory.description,
                  'icon': queryMultiAdapter((factory,request), name='zmi_icon'),
                  })

        self.wfs = workspaces
コード例 #2
0
    def __call__(self, context):
        wfs = []
        for name, wf in getAdapters((PersonalSpace(),), IWorkspaceFactory):
            if not IInactiveWorkspaceFactory.providedBy(wf):
                term = SimpleTerm(name, name, wf.title)
                term.description = wf.description
                wfs.append((wf.weight, wf.title, term))

        wfs.sort()
        return Vocabulary([term for _w, _t, term in wfs])
コード例 #3
0
ファイル: layout.py プロジェクト: Zojax/zojax.content.space
    def update(self):
        super(SpaceLayout, self).update()

        wsname = u''
        ws = self.mainview
        while not ISpace.providedBy(ws):
            if IWorkspace.providedBy(ws):
                wsname = ws.__name__
                break
            ws = ws.__parent__

        if not wsname:
            wsname = self.mainview.__name__

        self.workspace = ws

        context = self.context
        request = self.request

        if IContentSpaceLayout.providedBy(context):
            self.showHeader = context.showHeader
            self.title = context.title
        else:
            self.title = getMultiAdapter((context, request), IBreadcrumb).name

        if IContentSpaceLayout.providedBy(context) and not context.showTabs:
            return

        wfactories = []

        management = IWorkspacesManagement(context, None)
        if IWorkspacesManagement.providedBy(management):
            if management.enabledWorkspaces:
                for name in management.enabledWorkspaces:
                    factory = queryAdapter(context, IWorkspaceFactory, name)
                    if factory is not None \
                            and context.isEnabled(factory) \
                            and checkPermission('zope.View', factory.get()):
                        wfactories.append((name, factory))

        if not wfactories:
            for name, factory in getAdapters((context,), IWorkspaceFactory):
                if not IInactiveWorkspaceFactory.providedBy(factory) and \
                        not context.isEnabled(factory) or \
                        not checkPermission('zope.View', factory.get()):
                    continue
                wfactories.append((
                        factory.weight, factory.title, name, factory))

            wfactories.sort()
            wfactories = [(n, f) for _w, _t, n, f in wfactories]

        workspaces = []
        for name, factory in wfactories:
            workspaces.append(
                 {'name': name,
                  'title': factory.title,
                  'description': factory.description,
                  'selected': name == wsname,
                  'icon': queryMultiAdapter((factory,request), name='zmi_icon'),
                  })

        self.workspaces = workspaces
コード例 #4
0
    def update(self):
        super(PortalTabs, self).update()

        if not self.available:
            return

        site = self.context
        wsname = self.wsname
        request = self.request

        url = absoluteURL(site, self.request)

        selected = False

        wfactories = []
        if IWorkspacesManagement.providedBy(site):
            if site.enabledWorkspaces:
                for name in site.enabledWorkspaces:
                    factory = queryAdapter(site, IWorkspaceFactory, name)
                    if factory is not None and \
                            checkPermission('zope.View', factory.install()):
                        wfactories.append((name, factory))

        if not wfactories:
            for name, factory in getAdapters((site,), IWorkspaceFactory):
                if not IInactiveWorkspaceFactory.providedBy(factory) and \
                        not site.isEnabled(factory) or \
                        not checkPermission('zope.View', factory.install()):
                    continue
                wfactories.append((
                        factory.weight, factory.title, name, factory))

            wfactories.sort()
            wfactories = [(n, f) for _w, _t, n, f in wfactories]

        seen = set()
        workspaces = []
        for name, factory in wfactories:
            if name in seen:
                continue

            seen.add(name)

            if not site.isEnabled(factory):
                continue

            if name == wsname:
                selected = True

            workspaces.append(
                {'name': name,
                 'url': '%s/%s/'%(url, name),
                 'title': factory.title,
                 'description': factory.description,
                 'selected': name == wsname,
                 'icon': queryMultiAdapter((factory,request), name='zmi_icon')})

        if not selected:
            self.siteSelected = True
        else:
            self.siteSelected = False

        self.workspaces = workspaces