Exemplo n.º 1
0
    def addingInfo(self):
        """Return menu data.

        This is sorted by title.
        """
        container = self.context
        menu_service = zapi.getService("BrowserMenu")
        result = []
        for menu_id in (self.menu_id, 'zope.app.container.add'):
            if not menu_id:
                continue
            for item in menu_service.getMenu(menu_id, self, self.request):
                extra = item.get('extra')
                if extra:
                    factory = extra.get('factory')
                    if factory:
                        factory = zapi.getUtility(IFactory, factory)
                        if not checkFactory(container, None, factory):
                            continue
                        elif item['extra']['factory'] != item['action']:
                            item['has_custom_add_view'] = True
                result.append(item)

        result.sort(lambda a, b: cmp(a['title'], b['title']))
        return result
Exemplo n.º 2
0
    def addingInfo(self):
        """Return menu data.

        This is sorted by title.
        """
        container = self.context
        menu_service = zapi.getService("BrowserMenu")
        result = []
        for menu_id in (self.menu_id, 'zope.app.container.add'):
            if not menu_id:
                continue
            for item in menu_service.getMenu(menu_id, self, self.request):
                extra = item.get('extra')
                if extra:
                    factory = extra.get('factory')
                    if factory:
                        factory = zapi.getUtility(IFactory, factory)
                        if not checkFactory(container, None, factory):
                            continue
                        elif item['extra']['factory'] != item['action']:
                            item['has_custom_add_view']=True
                result.append(item)

        result.sort(lambda a, b: cmp(a['title'], b['title']))
        return result
Exemplo n.º 3
0
    def addingInfo(self):
        """Return menu data.

        This is sorted by title.
        """
        container = self.context
        result = []
        for menu_id in (self.menu_id, "zope.app.container.add"):
            if not menu_id:
                continue
            for item in getMenu(menu_id, self, self.request):
                extra = item.get("extra")
                if extra:
                    factory = extra.get("factory")
                    if factory:
                        factory = getUtility(IFactory, factory)
                        if not checkFactory(container, None, factory):
                            continue
                        elif item["extra"]["factory"] != item["action"]:
                            item["has_custom_add_view"] = True
                # translate here to have a localized sorting
                item["title"] = zope.i18n.translate(item["title"], context=self.request)
                result.append(item)

        # sort the adding info with a collator instead of a basic unicode sort
        collator = queryAdapter(self.request.locale, ICollator)
        if collator is None:
            collator = FallbackCollator(self.request.locale)
        result.sort(key=lambda x: collator.key(x["title"]))
        return result
Exemplo n.º 4
0
    def addingInfo(self):
        """Return menu data.

        This is sorted by title.
        """
        container = self.context
        result = []
        for menu_id in (self.menu_id, 'zope.app.container.add'):
            if not menu_id:
                continue
            for item in getMenu(menu_id, self, self.request):
                extra = item.get('extra')
                if extra:
                    factory = extra.get('factory')
                    if factory:
                        factory = getUtility(IFactory, factory)
                        if not checkFactory(container, None, factory):
                            continue
                        elif item['extra']['factory'] != item['action']:
                            item['has_custom_add_view']=True
                # translate here to have a localized sorting
                item['title'] = zope.i18n.translate(item['title'],
                                                    context=self.request)
                result.append(item)

        # sort the adding info with a collator instead of a basic unicode sort
        collator = queryAdapter(self.request.locale, ICollator)
        if collator is None:
            collator = FallbackCollator(self.request.locale)
        result.sort(key = lambda x: collator.key(x['title']))
        return result