コード例 #1
0
ファイル: vocabulary.py プロジェクト: Zojax/zojax.blogger
    def __call__(self, context):
        while True:
            if IBlog.providedBy(context):
                break

            if IDraftContent.providedBy(context):
                context = context.getLocation()
                if ISpace.providedBy(context):
                    context = context.get('blog')
                break

            context = getattr(context, '__parent__', None)
            if context is None:
                break

        if context is None:
            return SimpleVocabulary(())

        ids = getUtility(IIntIds)

        categories = []
        for category in context['category'].values():
            try:
                id = ids.getId(removeAllProxies(category))
            except:
                continue

            term = SimpleTerm(id, str(id), category.title)
            term.description = category.description

            categories.append((category.title, term))

        categories.sort()
        return SimpleVocabulary([term for title, term in categories])
コード例 #2
0
    def getMoreLink(self):
        context = self.context
        while not ISpace.providedBy(context):
            context = context.__parent__
            if context is None:
                break

        if context is not None:
            return u'%s/browse-documents.html'%absoluteURL(context, self.request)
コード例 #3
0
    def __init__(self, context, request, manager, view):
        while not ISpace.providedBy(context):
            context = getattr(context, '__parent__', None)
            if context is None:
                break

        context = context or getSite()

        super(RecentCommentsPortlet, self).__init__(
            context, request, manager, view)
コード例 #4
0
ファイル: indexes.py プロジェクト: Zojax/zojax.content.space
    def __init__(self, content, default=None):
        self.value = default

        while not ISpace.providedBy(content):
            content = getattr(content, '__parent__', None)
            if content is None:
                break

        if content is not None:
            self.value = getUtility(IIntIds).queryId(removeAllProxies(content))
コード例 #5
0
def CategoryIdsVocabulary(context):

    while True:

        if ISpace.providedBy(context):
            break

        if IDraftContent.providedBy(context):
            context = context.getLocation()
            break

        context = getattr(context, '__parent__', None)
        if context is None:
            break

    if context is None:
        return SimpleVocabulary(())

    getId = getUtility(IIntIds).getId
    terms = []

    while True:

        ws = queryAdapter(context, IWorkspaceFactory, name='media')

        if ws is not None and ws.isInstalled():
            for category in context['media']['category'].values():
                id = getId(removeAllProxies(category))
                term = SimpleTerm(id, str(id), category.title)
                term.description = category.description
                terms.append(term)

        if IPortal.providedBy(context):
            break

        context = getattr(context, '__parent__', None)
        if context is None or not ISpace.providedBy(context):
            break

    terms.sort(key=lambda t:t.title)

    return SimpleVocabulary(terms)
コード例 #6
0
def CategoryIdsVocabulary(context):

    while True:
        if ISpace.providedBy(context):
            break

        if IDraftContent.providedBy(context):
            context = context.getLocation()
            if context is not None:
                context = context.__parent__
            break

        context = getattr(context, '__parent__', None)
        if context is None:
            break

    if context is None:
        return SimpleVocabulary(())

    getId = getUtility(IIntIds).getId
    terms = []

    while True:
        wf = queryAdapter(context, IWorkspaceFactory, name='news')
        if wf is not None and wf.isInstalled():
            for category in context['news']['category'].values():
                id = getId(removeAllProxies(category))
                term = SimpleTerm(id, str(id), category.title)
                term.description = category.description
                terms.append((term.title, term))

        if ISite.providedBy(context):
            break

        context = getattr(context, '__parent__', None)
        if context is None or not ISpace.providedBy(context):
            break

    terms.sort()
    return SimpleVocabulary([term for _t, term in terms])
コード例 #7
0
ファイル: indexes.py プロジェクト: Zojax/zojax.content.space
    def __init__(self, content, default=None):
        spaces = []
        while content is not None:
            if ISpace.providedBy(content):
                spaces.append(content)

            content = getattr(content, '__parent__', None)

        ids = getUtility(IIntIds)

        value = []
        for space in spaces:
            id = ids.queryId(removeAllProxies(space))
            if id is not None:
                value.append(id)

        self.value = value
コード例 #8
0
ファイル: tags.py プロジェクト: Zojax/zojax.blogger
    def update(self):
        context = self.context
        while not ISpace.providedBy(context):
            context = context.__parent__

        try:
            blog = context.get('blog')
            if not IBlog.providedBy(blog):
                return
        except:
            return

        self.blog = True
        self.context = blog
        self.blog_url = absoluteURL(removeAllProxies(blog), self.request)

        super(BlogTagsPortlet, self).update()
コード例 #9
0
ファイル: layout.py プロジェクト: Zojax/zojax.content.space
    def update(self):
        super(WorkspaceLayout, self).update()

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

        self.workspace = ws

        view = self.mainview
        while not IContentWizard.providedBy(view):
            view = view.__parent__
            if view is None:
                break

        self.wizard = view is not None
コード例 #10
0
ファイル: search.py プロジェクト: Zojax/zojax.groups
    def update(self):
        context = self.context
        while not ISpace.providedBy(context):
            context = context.__parent__

        try:
            blog = context.get('blog')
            if not IBlog.providedBy(blog):
                return
        except:
            return

        if 'category' not in blog:
            return

        categories = []
        for category in blog['category'].values():
            categories.append((category.title, category.__name__))

        categories.sort()
        self.categories = [{'name':name, 'title':title} for title, name in categories]
コード例 #11
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