def js(self):
     thesaurus = utils.get_thesaurus_object(self.context)
     if thesaurus is None:
         return ''
     thesaurus_path = '/'.join(thesaurus.getPhysicalPath())
     return JS_TEMPLATE % dict(
         thesaurus_url=thesaurus_path
         )
 def __call__(self, context):
     # build vocab from first thesaurus returned by catalog
     thesaurus = utils.get_thesaurus_object(context)
     if thesaurus is None:
         return SimpleVocabulary([])
     thesaurus_path = '/'.join(thesaurus.getPhysicalPath())
     catalog = getToolByName(context, 'portal_catalog')
     results = catalog(portal_type='dmskeyword',
                       path={'query': thesaurus_path,'depth': 1})
     keyword_terms = [SimpleVocabulary.createTerm(
                             x.getId, x.getId, x.Title) for x in results]
     return SimpleVocabulary(keyword_terms)
 def displayItems(self):
     thesaurus = utils.get_thesaurus_object(self.context)
     thesaurus_path = '/'.join(thesaurus.getPhysicalPath())
     value = []
     for token in self.value:
         # Ignore no value entries. They are in the request only.
         if token == self.noValueToken:
             continue
         term = self.terms.getTermByToken(token)
         value.append(
             {'title': term.title,
              'href': thesaurus_path + '/' + term.value,
              })
     return value
Exemplo n.º 4
0
    def __call__(self, context):
        if context.portal_type == 'dmsthesaurus':
            thesaurus_path = '/'.join(context.getPhysicalPath())
        else:
            thesaurus = utils.get_thesaurus_object(context)
            if thesaurus is None:
                return SimpleVocabulary([])
            thesaurus_path = '/'.join(thesaurus.getPhysicalPath())
        catalog = getToolByName(context, 'portal_catalog')
        results = catalog(portal_type='dmskeyword',
                          path={'query': thesaurus_path,'depth': 1})
        keywords = [x.getObject() for x in results]

        keyword_terms = [SimpleVocabulary.createTerm(
                                x.id, x.id, x.title) for x in keywords]
        return SimpleVocabulary(keyword_terms)