当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.ITitledTokenizedTerm类代码示例

本文整理汇总了Python中zope.schema.interfaces.ITitledTokenizedTerm的典型用法代码示例。如果您正苦于以下问题:Python ITitledTokenizedTerm类的具体用法?Python ITitledTokenizedTerm怎么用?Python ITitledTokenizedTerm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ITitledTokenizedTerm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: items

 def items(self):
     items = []
     if self.terms is not None:
         # update() has been called
         if ((not self.required or self.prompt)
             and not bool(self.multiple)):
             message = self.noValueMessage
             if self.prompt:
                 message = self.promptMessage
             items.append({
                 'id': self.id + '-novalue',
                 'value': self.noValueToken,
                 'content': message,
                 'selected': self.value == []
                 })
         for count, term in enumerate(self.terms):
             selected = self.isSelected(term)
             id = '%s-%i' % (self.id, count)
             content = term.token
             if ITitledTokenizedTerm.providedBy(term):
                 content = translate(
                     term.title,
                     context=self.request,
                     default=term.title)
             items.append(
                 {'id':id,
                  'value':term.token,
                  'content':content,
                  'selected':selected})
     return items
开发者ID:damilgra,项目名称:collective.z3cform.chosen,代码行数:30,代码来源:widget.py

示例2: test_get_term_by_token

 def test_get_term_by_token(self):
     # we can get a term by its token
     source = RedisAutocompleteSource(
         host=self.redis_host, port=self.redis_port,
         zset_name="autocomplete-foo")
     result = source.getTermByToken(u'1')
     self.assertTrue(ITitledTokenizedTerm.providedBy(result))
开发者ID:clamor,项目名称:psj.content,代码行数:7,代码来源:test_sources.py

示例3: cmp

 def cmp(self, term, query):
     # ajax search widget does a search on this vocabulary,
     # if we have titled terms, we have to compare against the title
     # otherwise use the value.
     if ITitledTokenizedTerm.providedBy(term):
         return query in term.title.lower()
     return query in term.value.lower()
开发者ID:gu-eresearch,项目名称:gu.z3cform.rdf,代码行数:7,代码来源:vocabulary.py

示例4: items

    def items(self):
        # TODO: check if we should cache the return list
        if self.terms is None:  # update() not yet called
            return ()
        vocab = getUtility(
            IVocabularyFactory, "org.bccvl.site.algorithm_category_vocab")(self.context)
        items = OrderedDict((cat.value, [])
                            for cat in chain((SimpleTerm(None),), vocab))
        for count, term in enumerate(self.terms):
            alg = term.brain.getObject()
            # skip algorithm without category
            # if alg.algorithm_category is None or alg.algorithm_category not in items:
            #     continue
            itemList = items[alg.algorithm_category]
            checked = self.isChecked(term)
            id = '%s-%i' % (self.id, count)
            if ITitledTokenizedTerm.providedBy(term):
                label = translate(
                    term.title, context=self.request, default=term.title)
            else:
                label = util.toUnicode(term.value)

            catterm = SimpleTerm(None)
            if alg.algorithm_category in vocab:
                catterm = vocab.getTerm(alg.algorithm_category)
            itemList.append({'id': id, 'name': self.name + ':list', 'value': term.token,
                             'label': label, 'checked': checked,
                             'subject': term.brain.Subject,
                             'description': term.brain.Description,
                             'category': catterm,
                             'pos': len(itemList)})
        return items.values()
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:32,代码来源:widgets.py

示例5: users

    def users(self):
        context = self.context
        memtool = getToolByName(context, 'portal_membership')
        vocabulary = queryUtility(schema.interfaces.IVocabularyFactory,
                                  name='ftw.notification.base.users',
                                  context=context)
        if vocabulary:
            users = vocabulary(context)

            finalized = []
            for t in users:
                userid = t.value
                member = memtool.getMemberById(userid)
                if member is None:
                    continue

                title = t.title if ITitledTokenizedTerm.providedBy(t) else t.value
                user = dict(title=title,
                            value=t.value,
                            email=member.getProperty("email", ""),
                            selected=t.value in self.pre_select)
                finalized.append(user)

            finalized.sort(key=lambda user: user['title'].lower())
        return finalized
开发者ID:4teamwork,项目名称:ftw.notification.base,代码行数:25,代码来源:views.py

示例6: test_iter

 def test_iter(self):
     # we can iterate over all elements
     source = RedisAutocompleteSource(
         host=self.redis_host, port=self.redis_port,
         zset_name="autocomplete-foo")
     elem_list = [x for x in source]
     self.assertEqual(len(elem_list), 4)
     self.assertTrue(ITitledTokenizedTerm.providedBy(elem_list[0]))
开发者ID:clamor,项目名称:psj.content,代码行数:8,代码来源:test_sources.py

示例7: render_default_title

    def render_default_title(self, item, value):
        """Render the default title colum with the term's title."""

        term = self.terms.getTerm(item)

        if ITitledTokenizedTerm.providedBy(term):
            label = translate(term.title, context=self.request,
                              default=term.title)
        else:
            label = util.toUnicode(term.value)
        return label
开发者ID:lukasgraf,项目名称:opengever.core,代码行数:11,代码来源:widgets.py

示例8: test_get_term_contained

 def test_get_term_contained(self):
     # we can get contained terms as ITerm
     source = RedisSource(host=self.redis_host, port=self.redis_port)
     term = source.getTerm(u'foo')
     assert ITitledTokenizedTerm.providedBy(term)
     self.assertTrue(hasattr(term, 'value'))
     self.assertEqual(term.value, u'foo')
     self.assertTrue(hasattr(term, 'token'))
     self.assertEqual(term.token, 'Zm9v')
     self.assertTrue(hasattr(term, 'title'))
     self.assertEqual(term.title, u'bar')
开发者ID:clamor,项目名称:psj.content,代码行数:11,代码来源:test_sources.py

示例9: addItem

 def addItem(idx, group, term, prefix=''):
     selected = self.isSelected(term)
     if selected:
         ignored.remove(term.token)
     id = '%s-%s%i' % (self.id, prefix, idx)
     content = term.token
     if ITitledTokenizedTerm.providedBy(term):
         content = translate(
             term.title, context=self.request, default=term.title)
     optgroups[group].append(
         {'id': id, 'value': term.token, 'content': content,
          'selected': selected})
开发者ID:gu-eresearch,项目名称:gu.z3cform.rdf,代码行数:12,代码来源:groupedselect.py

示例10: render_default_title

    def render_default_title(self, item, value):
        """Render the default title colum with the term's title."""
        if isinstance(item, NullObject):
            return _(u'label_none', default=u'None')

        term = self.terms.getTerm(item)

        if ITitledTokenizedTerm.providedBy(term):
            label = translate(term.title, context=self.request,
                              default=term.title)
        else:
            label = util.toUnicode(term.value)
        return label
开发者ID:4teamwork,项目名称:opengever.core,代码行数:13,代码来源:widgets.py

示例11: textForValue

    def textForValue(self, term):
        """Extract a string from the `term`.

        The `term` must be a vocabulary tokenized term.

        This can be overridden to support more complex `term`
        objects. The token is returned here since it's the only thing
        known to be a string, or str()able.

        """
        if ITitledTokenizedTerm.providedBy(term):
            return self.translate(term.title)
        return term.token
开发者ID:wpjunior,项目名称:proled,代码行数:13,代码来源:itemswidgets.py

示例12: items

 def items(self):
     if self.terms is None:  # update() has not been called yet
         return ()
     items = []
     if self.multiple is None:
         message = self.noValueMessage
         if self.prompt:
             message = self.promptMessage
         items.append({
             'id': self.id + '-novalue',
             'value': self.noValueToken,
             'content': message,
             'selected': self.value == []
             })
     unordered_items = {}
     optgroups = []
     for count, term in enumerate(self.terms):
         # Exctract optgroups in an ordered list, so we can use this to
         # preserve the main order of optgroups.
         if not term.optgroup in optgroups:
             optgroups.append(term.optgroup)
         selected = self.isSelected(term)
         id = '%s-%i' % (self.id, count)
         content = term.title
         if ITitledTokenizedTerm.providedBy(term):
             content = self.getContent(term)
         if not term.optgroup in unordered_items:
             unordered_items[term.optgroup] = []
         unordered_items[term.optgroup].append({
             'id': id,
             'value': term.token,
             'content': content,
             'selected': selected,
         })
     for group in optgroups:
         if not group:
             for ding in unordered_items[group]:
                 items.append({
                     'id': ding['id'],
                     'value': ding['value'],
                     'content': ding['content'],
                     'selected': ding['value'] == []
                     })
         else:
             item = {}
             item['title'] = group
             item['member'] = unordered_items[group]
             items.append(item)
     self.getSize(items)
     return items
开发者ID:fourdigits,项目名称:z3c.formwidget.optgroup,代码行数:50,代码来源:widget.py

示例13: _overrideValue

    def _overrideValue(self, widget, value):
        if value:
            widget.value = ['selected']

        widget.items = []
        for count, term in enumerate(widget.terms):
            checked = widget.isChecked(term)
            id = '%s-%i' % (widget.id, count)
            label = term.token
            if ITitledTokenizedTerm.providedBy(term):
                label = translate(term.title, context=widget.request,
                                  default=term.title)
            widget.items.append({'id': id, 'name': widget.name + ':list',
                'value': term.token, 'label': label, 'checked': checked})
开发者ID:kroman0,项目名称:products,代码行数:14,代码来源:controlpanel.py

示例14: displayValue

 def displayValue(self):
     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)
         if ITitledTokenizedTerm.providedBy(term):
             content = self.getContent(term)
         else:
             value.append(term.value)
         if not term.optgroup in value:
             value[term.optgroup] = []
         value[term.optgroup].append(content)
     return value
开发者ID:fourdigits,项目名称:z3c.formwidget.optgroup,代码行数:15,代码来源:widget.py

示例15: items

 def items(self):
     # TODO: check if we should cache the return list
     if self.terms is None:  # update() not yet called
         return ()
     items = []
     for count, term in enumerate(self.terms):
         checked = self.isChecked(term)
         id = '%s-%i' % (self.id, count)
         if ITitledTokenizedTerm.providedBy(term):
             label = translate(term.title, context=self.request,
                               default=term.title)
         else:
             label = util.toUnicode(term.value)
         items.append ({'id': id, 'name': self.name + ':list', 'value':term.token,
                'label':label, 'checked': checked,
                'subject': term.brain.Subject})
     return items
开发者ID:sarahrichmond,项目名称:org.bccvl.site,代码行数:17,代码来源:widgets.py


注:本文中的zope.schema.interfaces.ITitledTokenizedTerm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。