コード例 #1
0
ファイル: browser.py プロジェクト: eea/plone.stringinterp
def find_adapters(reg):
    for a in reg.registeredAdapters():
        if len(a.required) == 1 and IStringSubstitution.implementedBy(a.factory):
            yield a
    for base in reg.__bases__:
        for a in find_adapters(base):
            yield a
コード例 #2
0
ファイル: browser.py プロジェクト: CGTIC/Plone_SP
    def substitutionList(self):
        """
        returns sequence:
        [ {'category':categoryTitle,
           'items':[{'id':subId, 'description':subDescription}, ...]), ...  ]
        """

        adapters = [a for a in getGlobalSiteManager().registeredAdapters()
                      if len(a.required)==1 and
                         IStringSubstitution.implementedBy(a.factory)]

        # rearrange into categories
        categories = {}
        for a in adapters:
            id = a.name
            cat = getattr(a.factory, 'category', _(u'Miscellaneous'))
            desc = getattr(a.factory, 'description', u'')
            categories.setdefault(cat, []).append(
              {'id': id, 'description': desc})

        # rearrange again into a sorted list
        res = []
        keys = categories.keys()
        # sort, ignoring case
        keys.sort(lambda a, b: cmp(a.lower(), b.lower()))
        for key in keys:
            acat = categories[key]
            # sort by id, ignoring case
            acat.sort(lambda a, b: cmp(a['id'].lower(), b['id'].lower()))
            res.append({'category': key, 'items': acat})

        return res
コード例 #3
0
ファイル: browser.py プロジェクト: nilbacardit26/plone_prova
def find_adapters(reg):
    for a in reg.registeredAdapters():
        if len(a.required) == 1 and IStringSubstitution.implementedBy(
                a.factory):
            yield a
    for base in reg.__bases__:
        for a in find_adapters(base):
            yield a
コード例 #4
0
    def substitutionList(self):
        """
        returns sequence:
        [ {'category':categoryTitle,
           'items':[{'id':subId, 'description':subDescription}, ...]), ...  ]
        """

        adapters = [
            a for a in getGlobalSiteManager().registeredAdapters()
            if len(a.required) == 1
            and IStringSubstitution.implementedBy(a.factory)
        ]

        # rearrange into categories
        categories = {}
        for a in adapters:
            id = a.name
            cat = getattr(a.factory, 'category', _(u'Miscellaneous'))
            desc = getattr(a.factory, 'description', u'')
            categories.setdefault(cat, []).append({
                'id': id,
                'description': desc
            })

        # rearrange again into a sorted list
        res = []
        keys = categories.keys()
        # sort, ignoring case
        keys.sort(lambda a, b: cmp(a.lower(), b.lower()))
        for key in keys:
            acat = categories[key]
            # sort by id, ignoring case
            acat.sort(lambda a, b: cmp(a['id'].lower(), b['id'].lower()))
            res.append({'category': key, 'items': acat})

        return res