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


Python SimpleVocabulary.createTerm方法代码示例

本文整理汇总了Python中zope.schema.vocabulary.SimpleVocabulary.createTerm方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleVocabulary.createTerm方法的具体用法?Python SimpleVocabulary.createTerm怎么用?Python SimpleVocabulary.createTerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zope.schema.vocabulary.SimpleVocabulary的用法示例。


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

示例1: __call__

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
 def __call__(self,context):
     acl_users = getToolByName(context, 'acl_users')
     group_list = acl_users.source_groups.getGroups()
     terms = [SimpleVocabulary.createTerm('Authenticated Users', 'Authenticated Users', 'Authenticated Users')]
     for group in group_list:
         terms.append(SimpleVocabulary.createTerm(group.getName(), group.getName() ,group.title or  group.getName()))
     return SimpleVocabulary(terms)
开发者ID:mamogmx,项目名称:iol.desktop,代码行数:9,代码来源:vocabularies.py

示例2: getTransitionVocab

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def getTransitionVocab(context):

    if AccessControl.getSecurityManager(
        ).getUser() == AccessControl.SpecialUsers.nobody:
        return SimpleVocabulary([])

    wftool = getToolByName(context, 'portal_workflow')
    transitions = []
    if opengever.task.task.ITask.providedBy(context) and \
            context.REQUEST.URL.find('++add++opengever.task.task') == -1:
        for tdef in wftool.getTransitionsFor(context):
            transitions.append(SimpleVocabulary.createTerm(
                    tdef['id'],
                    tdef['id'],
                    PMF(tdef['id'], default=tdef['title_or_id'])))
        return SimpleVocabulary(transitions)

    else:
        wf = wftool.get(wftool.getChainForPortalType('opengever.task.task')[0])
        state = wf.states.get(wf.initial_state)
        for tid in state.transitions:
            tdef = wf.transitions.get(tid, None)
            transitions.append(SimpleVocabulary.createTerm(
                    tdef.id,
                    tdef.id,
                    PMF(tdef.id, default=tdef.title_or_id)))
        return SimpleVocabulary(transitions)
开发者ID:pemzurigo,项目名称:opengever.core,代码行数:29,代码来源:util.py

示例3: list_templates

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def list_templates(context):
    """Return a list available templates."""
    templates = get_oneoffixx_templates()
    template_group = context.REQUEST.form.get('form.widgets.template_group')
    terms = []

    for template in templates:
        terms.append(SimpleVocabulary.createTerm(
            template, template.template_id, template.title))

    # We filter templates when template_group has been selected
    if template_group is not None:
        favorites = get_oneoffixx_favorites()
        # Favorites are a special case
        if favorites and template_group[0] == favorites.get('id'):
            terms = [
                SimpleVocabulary.createTerm(
                    OneOffixxTemplate(
                        template, favorites.get('localizedName', '')),
                    template.get('id'),
                    template.get('localizedName'),
                )
                for template in favorites.get('templates')
            ]
        elif template_group[0] != '--NOVALUE--':
            terms = [term for term in terms if term.value.group == template_group[0]]

    return MutableObjectVocabulary(terms)
开发者ID:4teamwork,项目名称:opengever.core,代码行数:30,代码来源:form.py

示例4: attachable_documents_vocabulary

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def attachable_documents_vocabulary(context):
    terms = []

    user = AccessControl.getSecurityManager().getUser()
    if user == AccessControl.SpecialUsers.nobody:
        return SimpleVocabulary(terms)

    intids = getUtility(IIntIds)

    ids = []

    for doc in context.getFolderContents(
        full_objects=True,
        contentFilter={'portal_type': ['opengever.document.document',
                                       'ftw.mail.mail']}):

        key = str(intids.getId(doc))
        label = doc.Title()
        terms.append(SimpleVocabulary.createTerm(key, key, label))
        ids.append(key)

    for relation in getattr(context, 'relatedItems', []):
        key = str(relation.to_id)
        # check if the task doesn't contain the related document allready
        if key in ids:
            continue
        label = relation.to_object.Title()
        terms.append(SimpleVocabulary.createTerm(key, key, label))

    return SimpleVocabulary(terms)
开发者ID:pemzurigo,项目名称:opengever.core,代码行数:32,代码来源:vocabulary.py

示例5: __call__

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
    def __call__(self, context):
        terms = []
        terms.append(SimpleVocabulary.createTerm(u'Català', 'ca', _(u'Català')))
        terms.append(SimpleVocabulary.createTerm(u'Castellà', 'es', _(u'Español')))
        terms.append(SimpleVocabulary.createTerm(u'English', 'en', _(u'English')))

        return SimpleVocabulary(terms)
开发者ID:UPCnet,项目名称:ulearn.core,代码行数:9,代码来源:controlpanel.py

示例6: MetadataVocabulary

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def MetadataVocabulary(context):
    """
    Metadata name is stored in registry. Format for default name is "fieldname:"
    and format for custom name is ":customname"
    """
    terms = []
    portal = getSite()
    metadataDisplay = getToolByName(portal, 'portal_atct').getMetadataDisplay()
    for name, display_name in metadataDisplay.items():
        if name in ['end', 'EffectiveDate', 'start', 'ExpirationDate', 'ModificationDate', 'CreationDate']:
            for format,format_name in [('localshort', 'Date'),('locallong','Date & Time')]:
                terms.append(SimpleVocabulary.createTerm("%s:%s"% (name, format), None,
                                                         "%s (%s)"%(display_name, format_name)))
        elif name in ['Title', 'getId']:
            terms.append(SimpleVocabulary.createTerm(name + ":", None, display_name))
            for format,format_name in [('tolink', 'Link')]:
                terms.append(SimpleVocabulary.createTerm("%s:%s"% (name, format), None,
                                                         "%s (%s)"%(display_name, format_name)))
        else:
            terms.append(SimpleVocabulary.createTerm(name + ":", None, display_name))

    # custom field
    reg = queryUtility(IRegistry)
    if reg is not None:
        proxy = ComplexRecordsProxy(reg, IListingCustomFieldControlPanel,
                                    prefix='collective.listingviews.customfield',
                                   key_names={'fields': 'id'})
        for field in proxy.fields:
            terms.append(SimpleVocabulary.createTerm(':' + field.id, None,
                                                     "%s (Custom)" % field.name))
    return SimpleVocabulary(terms)
开发者ID:jean,项目名称:collective.listingviews,代码行数:33,代码来源:interfaces.py

示例7: __call__

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
    def __call__(self, context):
        acl_users = getToolByName(context, 'acl_users')
        try:
            miColeccion=context.coleccionR[0].to_object
            idGAsign=IColecGroupName(miColeccion).groupName
        except:
            print "No se puedo asignar IColectGroupName"
            return SimpleVocabulary([SimpleVocabulary.createTerm("", str(""), "")])
        idGPot=idGAsign.replace("_g",PREFIJO_COOR_POTENCIAL)

        grupoPot= acl_users.getGroupById(idGPot)
        grupoAsignado=acl_users.getGroupById(idGAsign)

        terms = []
        listIds=[]
        if grupoPot is not None:
            for member_id in grupoPot.getMemberIds()+grupoAsignado.getMemberIds():
                if member_id not in listIds:
                    user = acl_users.getUserById(member_id)
                    if user is not None:
                        member_name = user.getProperty('fullname') or member_id
                        listIds.append(member_id)
                        terms.append(SimpleVocabulary.createTerm(member_id, str(member_id), member_name))

            return SimpleVocabulary(terms)
            
        #devulve un registro vacio
        return SimpleVocabulary([SimpleVocabulary.createTerm("", str(""), "")])
开发者ID:termoHead,项目名称:portal-arcas,代码行数:30,代码来源:vocabularios.py

示例8: availableDonationForms

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def availableDonationForms(context):
    terms = []
    settings = get_settings()
    default = settings.default_donation_form
    terms.append(SimpleVocabulary.createTerm(default, default,
                                             'Stripe Donation Form'))

    try:
        campaign_getter = context.get_fundraising_campaign

    except AttributeError:
        # The campaign hasn't been created yet, so there are no
        # available campaign-specific donation forms yet.
        pass

    else:
        campaign = campaign_getter()
        query = {
            "portal_type": "collective.salesforce.fundraising.productform",
            "path": '/'.join(campaign.getPhysicalPath()),
        }

        pc = getToolByName(context, 'portal_catalog')
        res = pc.searchResults(**query)
        for form in res:
            form_id = form.id + '/donation_form_stripe'
            terms.append(
                SimpleVocabulary.createTerm(form_id, form_id,
                                            'Product Form: ' + form.Title))

    return SimpleVocabulary(terms)
开发者ID:innocenceproject,项目名称:collective.salesforce.fundraising,代码行数:33,代码来源:fundraising_campaign.py

示例9: __call__

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
 def __call__(self, context):
     terms = []
     empty = 'Not defined (DEFAULT)'
     terms.append(SimpleVocabulary.createTerm(empty, str(empty), empty))
     extenders = [a[0] for a in getUtilitiesFor(ICatalogFactory) if a[0].startswith('user_properties') and a[0] != 'user_properties']
     for extender in extenders:
         terms.append(SimpleVocabulary.createTerm(extender, str(extender), extender))
     return SimpleVocabulary(terms)
开发者ID:UPCnet,项目名称:genweb.controlpanel,代码行数:10,代码来源:core.py

示例10: ViewletsTemplatesVocabFactory

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def ViewletsTemplatesVocabFactory(context):
    """ Vocabulary for potential vielets renderers listing """
    terms = [
        SimpleVocabulary.createTerm(name, name, u'%s (%s)' % (name, adapter.title))
        for name, adapter in getAdapters((context, context.REQUEST), IViewletResultsRenderer)
    ]
    terms.insert(0, SimpleVocabulary.createTerm('', '', u'None'))
    return SimpleVocabulary(terms)
开发者ID:collective,项目名称:collective.viewlet.pythonscript,代码行数:10,代码来源:vocabulary.py

示例11: flattrLanguageVocab

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def flattrLanguageVocab(context):
    portal = getToolByName(context, "portal_url").getPortalObject()
    flattr = getMultiAdapter((portal, context.REQUEST), name="collective_flattr")
    languages = flattr.getLanguages()
    terms = [SimpleVocabulary.createTerm("sysdefault", "sysdefault", _(u"System default"))]
    for lang in languages:
        terms.append(SimpleVocabulary.createTerm(lang["id"], lang["id"], lang["text"]))
    return SimpleVocabulary(terms)
开发者ID:chrigl,项目名称:docker-library,代码行数:10,代码来源:vocab.py

示例12: if_not_found_list

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
def if_not_found_list(context):
    terms = [SimpleVocabulary.createTerm('__ignore__', '__ignore__', 'Skip'),
             SimpleVocabulary.createTerm('__stop__', '__stop__', 'Stop')]


    for fti in get_allowed_types(context):
        portal_type = fti.getId()
        terms.append(SimpleVocabulary.createTerm(portal_type, portal_type,
                                                 "Create %s" % fti.title))
    return SimpleVocabulary(terms)
开发者ID:collective,项目名称:collective.importexport,代码行数:12,代码来源:import_view.py

示例13: __call__

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
 def __call__(self, context):
     tracker = aq_parent(context)
     myField = tracker.getField(self.field)
     result = []
     for item in myField.get(tracker):
         result.append(SimpleVocabulary.createTerm(
                 item['id'], item['id'], item['title']))
     if result == []:
         result.append(SimpleVocabulary.createTerm(
                 '', '', '-'))
     return result
开发者ID:4teamwork,项目名称:izug.ticketbox,代码行数:13,代码来源:vocabularies.py

示例14: __call__

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
    def __call__(self,context):
        contexto=getSite()
        catalogo= getToolByName(contexto, 'portal_catalog')
        results=catalogo.unrestrictedSearchResults({'object_provides': IColeccion.__identifier__,'review_state':('SetUp','Publicado')})
        terms = []
        if len(results)>0:
            for colec in results:
                terms.append(SimpleVocabulary.createTerm(colec.id, str(colec.id), colec.Title))
        else:
            terms.append(SimpleVocabulary.createTerm("", "", ""))

        return SimpleVocabulary(terms)
开发者ID:termoHead,项目名称:portal-arcas,代码行数:14,代码来源:vocabulario.py

示例15: __call__

# 需要导入模块: from zope.schema.vocabulary import SimpleVocabulary [as 别名]
# 或者: from zope.schema.vocabulary.SimpleVocabulary import createTerm [as 别名]
 def __call__(self, context):
     acl_users = getToolByName(context, 'acl_users')
     group = acl_users.getGroupById(self.group_name)
     terms = []
     terms.append(SimpleVocabulary.createTerm('', str(''), ''))
     if group is not None:
         for member_id in group.getMemberIds():
             user = acl_users.getUserById(member_id)
             if user is not None:
                 member_name = user.getProperty('fullname') or member_id
                 terms.append(SimpleVocabulary.createTerm(member_id, str(member_id), member_name))
         
     return SimpleVocabulary(terms)    
开发者ID:renfers,项目名称:ageliaco.rd,代码行数:15,代码来源:cycle.py


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