Exemplo n.º 1
0
def getTagsAndTagsCount(results):

    from Products.Archetypes.atapi import Vocabulary, DisplayList
    from Products.Archetypes.utils import unique
    coll = {}

    for o in results:
        lstSubject = []
        try:
            lstSubject = o.Subject
        except AttributeError:
            from p4a.plonecalendar.eventprovider import BrainEvent
            if isinstance(o,BrainEvent):
                lstSubject = o.context.Subject
            else:
                lstSubject = []
        for eSub in lstSubject:
            if coll.get(eSub,None) is None:
                coll[eSub] = {'name':eSub,'count':1}
            else:
                coll[eSub]['count'] = coll.get(eSub)['count'] + 1

    dl = DisplayList()
    collkeys = coll.keys()
    collkeys.sort(lambda x,y: cmp(x.lower(),y.lower()),reverse=False)

    for obj in collkeys:
        dl.add(coll[obj]['name'],coll[obj]['count'])

    return Vocabulary(dl,None,None)
 def makeVocab(self, list):
     """Takes in a list (of keywords) and returns a Vocabulary without a
     translation domain.
     """
     dl = DisplayList()
     for i in list:
         dl.add(i, i)
     return Vocabulary(dl, None, None)
Exemplo n.º 3
0
 def removeI18nDomain(self, vocab):
     if not isinstance(vocab, (Vocabulary, DisplayList)):
         raise ValueError("Not a vocabulary or DisplayList!")
     return Vocabulary(vocab, None, None)