grok.implements(IVocabularyFactory) def __call__(self, context): terms = [] levels = [ ('morning', _(u'Morning')), ('afternon', _(u'Afternon')), ] for code, text in levels: term = (code, code, text) terms.append(SimpleVocabulary.createTerm(*term)) return SimpleVocabulary(terms) grok.global_utility(PeriodsVocabulary, name=u"collective.conference.periods") class DurationVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): terms = [] levels = [ ('half_day', _(u'Half day')), ('one_day', _(u'1 day')), ('two_days', _(u'2 days')), ] for code, text in levels: term = (code, code, text) terms.append(SimpleVocabulary.createTerm(*term))
registry = getUtility(IRegistry) return registry.forInterface(IChimpdrillSettings, False) class IMailsnakeConnection(Interface): def get_mailchimp(): """ Returns a Mailsnake connection instance to the Mailchimp API """ def get_mandrill(): """ Returns a Mailsnake connection instance to the Mailchimp API """ class MailsnakeConnection(object): grok.implements(IMailsnakeConnection) def lookup_key(self, api): settings = get_settings() if api is None or api == 'api': return settings.mailchimp_api_key if api == 'mandrill': return settings.mandrill_api_key def get_connection(self, api): key = self.lookup_key(api) return MailSnake(key, api=api) def get_mailchimp(self): return self.get_connection('api') def get_mandrill(self): return self.get_connection('mandrill') grok.global_utility(MailsnakeConnection, provides=IMailsnakeConnection)
from five import grok from zope.schema.interfaces import IContextSourceBinder from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.component import getUtility from z3c.formwidget.query.interfaces import IQuerySource SCHEMES_CSS = { "red": "wcc-scheme-red.css", "blue": "wcc-scheme-blue.css", "darkgreen": "wcc-scheme-darkgreen.css", "pantone377": "wcc-scheme-pantone377.css", "brown": "wcc-scheme-brown.css", } class ColorSchemes(object): def __call__(self, context): return SimpleVocabulary.fromValues(SCHEMES_CSS.keys()) grok.global_utility(ColorSchemes, IVocabularyFactory, name="wcc.theme.colorscheme")
('inline', 'inline', _(u'inline')), ('upload', 'upload', _(u'upload')), ('reference', 'reference', _(u'reference')), ] source_type_terms = [ SimpleTerm(value, token, title) for value, token, title in source_type ] class SourceType(object): def __call__(self, context): return SimpleVocabulary(source_type_terms) grok.global_utility(SourceType, IVocabularyFactory, name="emc.bokeh.vocabulary.sourcetype") axis_type = [ ('linear', 'linear', _(u'Linear coordinate')), ('log', 'log', _(u'logarithmic coordinate')), ('datetime', 'date', _(u'Date time')), ] axis_type_terms = [ SimpleTerm(value, token, title) for value, token, title in axis_type ] class AxisType(object): def __call__(self, context): return SimpleVocabulary(axis_type_terms)
site. """ implements(IVocabularyFactory) def __call__(self, context): items = [] for route_name in getRouteNames(): route = getRoute(route_name) if not route: continue items.append(SimpleVocabulary.createTerm(route.name, route.name, route.name)) return SimpleVocabulary(items) grok.global_utility(RoutesVocabulary, name=u'collective.routes.Routes') class IRoutesSettings(Interface): """ Interface describing the settings on the control panel """ routes = schema.Set( title=_(u"Available Routes"), description=_(u""), value_type=schema.Choice(vocabulary=u"collective.routes.Routes"), default=set([]), missing_value=set([]), required=False, ) class RoutesSettingsEditForm(controlpanel.RegistryEditForm):
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) def __iter__(self): # hack to let schema editor handle the field yield u'DO NOT TOUCH' grok.global_utility(SimpleThesaurusSource, name=u'dms.thesaurus.simple') class KeywordFromSameThesaurusSource(object): """This vocabulary is used for keywords that reference one another inside the same thesaurus. It should not be used for referencing keywords from other content types. """ grok.implements(IVocabularyFactory) 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:
from five import grok from zope.schema.interfaces import IContextSourceBinder from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.component import getUtility from z3c.formwidget.query.interfaces import IQuerySource import pycountry DENOMINATIONS = [ {"id": "catholic", "title": "Catholic"}, {"id": "protestant", "title": "Protestant"}, {"id": "independent", "title": "Independent"}, ] class VocabularyFactory(object): def __call__(self, context): terms = [SimpleTerm(value=i["id"], title=i["title"]) for i in DENOMINATIONS] return SimpleVocabulary(terms) grok.global_utility(VocabularyFactory, IVocabularyFactory, name="wcc.vocabulary.denomination")
def get_telefon(self): return self._getProperty('telefon') def set_telefon(self, value): return self.context.setMemberProperties({'telefon': value}) telefon = property(get_telefon, set_telefon) def get_language(self): return self._getProperty('language') def set_language(self, value): return self.context.setMemberProperties({'language': value}) language = property(get_language, set_language) @implementer(ICatalogFactory) class UserNewsSearchSoupCatalog(object): def __call__(self, context): catalog = Catalog() idindexer = NodeAttributeIndexer('id') catalog['id'] = CatalogFieldIndex(idindexer) hashindex = NodeAttributeIndexer('searches') catalog['searches'] = CatalogKeywordIndex(hashindex) return catalog grok.global_utility(UserNewsSearchSoupCatalog, name='user_news_searches')
if settings.spreedly_login and settings.spreedly_secret: connect = spreedlycore.APIConnection(settings.spreedly_login, settings.spreedly_secret) gateways = connect.gateways() for gateway in gateways: terms.append( SimpleVocabulary.createTerm( unicode(gateway.token), unicode(gateway.token), unicode(gateway.data['gateway_type'] + ' | ' + gateway.data['created_at'].strftime( "%d-%b-%Y %H:%M GMT")))) return SimpleVocabulary(terms) grok.global_utility(GatewayVocabulary, name=u"mooball.plone.spreedlycore.Gateway") class ISpreedlyLoginSettings(zope.interface.Interface): """ Global Spreedly Login settings. This describes records stored in the configuration registry and obtainable via plone.registry. """ spreedly_login = zope.schema.TextLine( title=_(u"Spreedly Login"), description=_(u"spreedly_login", default=u"Login to Spreedly."), required=True, default=None, ) spreedly_secret = zope.schema.TextLine(
from zope.schema.interfaces import IContextSourceBinder from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.component import getUtility from z3c.formwidget.query.interfaces import IQuerySource import pycountry DENOMINATIONS = [{ 'id': 'catholic', 'title': 'Catholic' }, { 'id': 'protestant', 'title': 'Protestant', }, { 'id': 'independent', 'title': 'Independent' }] class VocabularyFactory(object): def __call__(self, context): terms = [ SimpleTerm(value=i['id'], title=i['title']) for i in DENOMINATIONS ] return SimpleVocabulary(terms) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='wcc.vocabulary.denomination')
('train', 'train', _(u'train')), ('simulation', 'simulation', _(u'simulation')), ('experiment', 'experiment', _(u'experiment')), ] task_type_terms = [ SimpleTerm(value, token, title) for value, token, title in task_type ] class taskType(object): def __call__(self, context): return SimpleVocabulary(task_type_terms) grok.global_utility(taskType, IVocabularyFactory, name="emc.project.vocabulary.tasktype") #密级属性:内部/秘密/机密/绝密 # 公开/内部/普通商业秘密/秘密/核心商业秘密/机密 security_level = [ ('public', 'public', _(u'public')), ('inner', 'inner', _(u'inner')), ('low', 'low', _(u'normal business secret')), ('secret', 'secret', _(u'secret')), ('high', 'high', _(u'high business secret')), ('highest', 'highest', _(u'highest secret')), ] security_level_terms = [ SimpleTerm(value, token, title) for value, token, title in security_level ]
def __call__(self, context): return self.thank_you_templates(context) def thank_you_templates(self, context): query = { "portal_type" : "collective.chimpdrill.template" } terms = [] pc = getToolByName(getSite(), 'portal_catalog') res = pc.searchResults(**query) for template in res: obj = template.getObject() uuid = IUUID(obj) if obj.template_schema == 'collective.salesforce.fundraising.chimpdrill.IThankYouEmail': terms.append(SimpleVocabulary.createTerm(uuid, uuid, obj.title)) return SimpleVocabulary(terms) grok.global_utility(ThankYouTemplates, name=u'collective.salesforce.fundraising.thank_you_templates') class HonoraryTemplates(object): grok.implements(IVocabularyFactory) def __call__(self, context): return self.honorary_templates(context) def honorary_templates(self, context): query = { "portal_type" : "collective.chimpdrill.template" } terms = [] pc = getToolByName(getSite(), 'portal_catalog') res = pc.searchResults(**query) for template in res: obj = template.getObject() uuid = IUUID(obj)
}, 'size': 1000 }) shared_items = [a['_source'] for a in shared_items['hits']['hits']] # Tha is_shared is still required? results = [format_item(a) for a in shared_items if is_shared(a)] # Ordena els resultats per title results.sort(key=lambda a: a['title'].lower()) return results grok.global_utility(ElasticSharing) class SharedWithMe(grok.View): grok.context(Interface) grok.name('shared_with_me') grok.require('genweb.authenticated') grok.layer(IUlearnTheme) def render(self): """ AJAX view to access shared items of the current logged in user """ self.request.response.setHeader('Content-type', 'application/json') results = [] sharing = queryUtility(IElasticSharing)
userindexer = NodeAttributeIndexer('username') catalog['username'] = CatalogTextIndex(userindexer) fullname = NodeAttributeIndexer('fullname') catalog['fullname'] = CatalogTextIndex(fullname) email = NodeAttributeIndexer('email') catalog['email'] = CatalogTextIndex(email) location = NodeAttributeIndexer('location') catalog['location'] = CatalogTextIndex(location) dni = NodeAttributeIndexer('dni') catalog['dni'] = CatalogTextIndex(dni) user_type = NodeAttributeIndexer('user_type') catalog['user_type'] = CatalogTextIndex(user_type) check_ubicacio = NodeAttributeIndexer('check_ubicacio') catalog['check_ubicacio'] = CatalogTextIndex(check_ubicacio) ubicacio = NodeAttributeIndexer('ubicacio') catalog['ubicacio'] = CatalogTextIndex(ubicacio) check_telefon = NodeAttributeIndexer('check_telefon') catalog['check_telefon'] = CatalogTextIndex(check_telefon) telefon = NodeAttributeIndexer('telefon') catalog['telefon'] = CatalogTextIndex(telefon) check_twitter_username = NodeAttributeIndexer('check_twitter_username') catalog['check_twitter_username'] = CatalogTextIndex( check_twitter_username) twitter_username = NodeAttributeIndexer('twitter_username') catalog['twitter_username'] = CatalogTextIndex(twitter_username) return catalog grok.global_utility(UserPropertiesSoupCatalogFactoryDEMO, name='user_properties_demo')
#from incf.countryutils import data as countrydata from my315ok.socialorgnization import _ announcement_type=[ ('chengli','chengli',_(u'chengli')), ('biangeng','biangeng',_(u'biangeng')), ('zhuxiao','zhuxiao',_(u'zhuxiao')), ] announcement_type_terms = [SimpleTerm(value, token, title) for value, token, title in announcement_type ] class AnnouncementType(object): def __call__(self, context): return SimpleVocabulary(announcement_type_terms) grok.global_utility(AnnouncementType, IVocabularyFactory, name="my315ok.socialorgnization.vocabulary.announcementtype") organization_type=[ ('shetuan','shetuan',_(u'shetuan')), ('minfei','minfei',_(u'minfei')), ('jijinhui','jijinhui',_(u'jijinhui')), ] organization_type_terms = [SimpleTerm(value, token, title) for value, token, title in organization_type ] class OrganizationType(object): def __call__(self, context): return SimpleVocabulary(organization_type_terms) grok.global_utility(OrganizationType, IVocabularyFactory, name="my315ok.socialorgnization.vocabulary.organizationtype")
# CLASSIFICATION: Vocabulary and default value CLASSIFICATION_UNPROTECTED = u'unprotected' CLASSIFICATION_CONFIDENTIAL = u'confidential' CLASSIFICATION_CLASSIFIED = u'classified' CLASSIFICATION_OPTIONS = ( # Option- # Option Name # level # (1, CLASSIFICATION_UNPROTECTED), (2, CLASSIFICATION_CONFIDENTIAL), (3, CLASSIFICATION_CLASSIFIED), ) grok.global_utility(utils.create_restricted_vocabulary( IClassification['classification'], CLASSIFICATION_OPTIONS, message_factory=_), provides=schema.interfaces.IVocabularyFactory, name=u'classification_classification_vocabulary') form.default_value(field=IClassification['classification'])( utils.set_default_with_acquisition(field=IClassification['classification'], default=CLASSIFICATION_UNPROTECTED)) # PUBLIC: Vocabulary and default value PUBLIC_TRIAL_UNCHECKED = u'unchecked' PUBLIC_TRIAL_PUBLIC = u'public' PUBLIC_TRIAL_PRIVATE = u'private' PUBLIC_TRIAL_OPTIONS = ( (1, PUBLIC_TRIAL_UNCHECKED), (2, PUBLIC_TRIAL_PUBLIC), (3, PUBLIC_TRIAL_PRIVATE),
"""Describe an HTML attribute. """ name = schema.TextLine(title=u"Attribute name", required=True) value = schema.TextLine(title=u"Attribute value", required=True) class CKEditorHTMLAttribute(object): grok.implements(ICKEditorHTMLAttribute) def __init__(self, name, value): self.name = name self.value = value grok.global_utility(CKEditorHTMLAttribute, provides=IFactory, name=ICKEditorHTMLAttribute.__identifier__, direct=True) class ICKEditorFormat(interface.Interface): """Describe a CKEditor Format style. """ name = schema.TextLine(title=u"Format name", required=True) element = schema.TextLine(title=u"HTML Element", required=True) attributes = schema.List( title=u"HTML Attributes", value_type=schema.Object(title=u"HTML Attribute", schema=ICKEditorHTMLAttribute), required=False, )
from five import grok from simple_salesforce import Salesforce from plone.registry.interfaces import IRegistry from collective.simplesalesforce.controlpanel import ISalesforceSettings def get_settings(): registry = getUtility(IRegistry) return registry.forInterface(ISalesforceSettings, False) class ISalesforceUtility(Interface): """ A global utility providing methods to access the Salesforce REST API """ def get_connection(): """ returns a simple salesforce connection instance """ class SalesforceUtility(object): grok.implements(ISalesforceUtility) def get_connection(self): settings = get_settings() sf = Salesforce( username=settings.username, password=settings.password, security_token=settings.security_token, sandbox=settings.sandbox ) return sf grok.global_utility(SalesforceUtility, provides=ISalesforceUtility)
class PeriodsVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): terms = [] levels = [('morning', _(u'Morning')), ('afternon', _(u'Afternon'))] for code, text in levels: term = (code, code, text) terms.append(SimpleVocabulary.createTerm(*term)) return SimpleVocabulary(terms) grok.global_utility(PeriodsVocabulary, name=u"collective.conference.periods") class DurationVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): terms = [] levels = [('half_day', _(u'Half day')), ('one_day', _(u'1 day')), ('two_days', _(u'2 days'))] for code, text in levels: term = (code, code, text) terms.append(SimpleVocabulary.createTerm(*term)) return SimpleVocabulary(terms)
"Project Design", "Project Management", "Psycho-Social Issues", "Public Sector - Government", "Public Sector - Health", "Public Sector - Infrastructure", "Crisis & Risk Assessment", "Skills Development", "Small Enterprise Development", "Social Dialogue", "Social Security", "Social Protection", "Statistical Analysis", "Strategic Planning", "Surveys", "Sustainable Enterprises", "Training Of Trainers", "Workers' Rights", "Youth, Adolescent Development", ] class VocabularyFactory(object): def __call__(self, context): return SimpleVocabulary.fromValues(subject_expertise) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='ilo.vocabulary.subject_expertise')
self._conn = None def __call__(self): return self.connection def create_new_connection(self): self.es_url = api.portal.get_registry_record( 'genweb.controlpanel.core.IGenwebCoreControlPanelSettings.elasticsearch' ) self._conn = Elasticsearch(self.es_url) @property def connection(self): if self._conn is None: self.create_new_connection() return self._conn grok.global_utility(ElasticSearch) class ReloadESConfig(grok.View): """ Convenience view for faster debugging. Needs to be manager. """ grok.context(Interface) grok.require('cmf.ManagePortal') grok.name('reload_es_config') def render(self): es = getUtility(IElasticSearch) es.reload = True
'Madagascar', 'Malawi', 'Malaysia', 'Maldives (The Republic of)', 'Mali', 'Malta', 'Marshall Islands', 'Mauritania', 'Mauritus', 'Mexico', 'Mongolia', 'Montenegro', 'Morocco', 'Myanmar', 'Mozambique', 'Namibia', 'Nauru', 'Nepal', 'New Zealand', 'the Netherlands', 'Niue', 'Nicaragua', 'the Niger', 'Nigeria', 'Norway', 'Oman', 'Pakistan', 'Palau (The Republic of)', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Quatar', 'Romania', 'the Russian Federation', 'Rwanda', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Republic of Korea', 'Samoa', 'Singapore (The Republic of)', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'South Sudan', 'Spain', 'Sri Lanka', 'the Sudan', 'Suriname', 'Swaziland', 'Sweden', 'Switzerland', 'Tajikistan', 'Thailand (The Kingdom of)', 'Timor-Leste', 'Togo', 'Tokelau', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'the United Kingdom', 'the United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Viet Nam (The Socialist Republic of)', 'Yemen', 'Zambia', 'Zimbabwe', 'HQ', 'ITC Turin', 'Other' ] class VocabularyFactory(object): def __call__(self, context): return SimpleVocabulary.fromValues(sorted(VALUES)) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='ilo.vocabulary.countries')
currency=settings.currency, card=token, description=description, **kwargs) return res def create_customer(self, token, description, context=None, **kwargs): settings = get_settings() stripe = self.get_stripe_api(context=context) res = stripe.Customer.create(card=token, description=description, **kwargs) return res def subscribe_customer(self, customer_id, plan, quantity, context=None, **kwargs): settings = get_settings() stripe = self.get_stripe_api(context=context) cu = stripe.Customer.retrieve(customer_id) res = cu.update_subscription(plan=plan, quantity=quantity, **kwargs) return res grok.global_utility(StripeUtility, provides=IStripeUtility)
title = collection.Title items.append(SimpleVocabulary.createTerm(path, path, title)) return SimpleVocabulary(items) def isPlone42(self): try: site = getSite() migrationTool = getToolByName(site, 'portal_migration') versions = migrationTool.coreVersions()['Plone'].split('.') return versions[0] == '4' and versions[1] == '2' except: return False grok.global_utility(NewsSourcesVocabulary, name=u'collective.newsticker.NewsSources') class NewsTickerSettingsEditForm(controlpanel.RegistryEditForm): schema = INewsTickerSettings label = _(u'News Ticker Settings') description = _(u'Here you can modify the settings for ' 'collective.newsticker.') def updateFields(self): super(NewsTickerSettingsEditForm, self).updateFields() def updateWidgets(self): super(NewsTickerSettingsEditForm, self).updateWidgets()
'capital': 'Juba' }, ] COUNTRY_TERMS = [ SimpleTerm(value=c['code'], title='%s (%s)' % (c['name'], c['code'])) for c in sorted(COUNTRIES, key=lambda x: x['name']) ] COUNTRY_CODE_NAMES = dict([(c['code'], c['name']) for c in COUNTRIES]) class VocabularyFactory(object): def __call__(self, context): return SimpleVocabulary(COUNTRY_TERMS) def name_from_code(self, code): return COUNTRY_CODE_NAMES[code] grok.global_utility(VocabularyFactory, IVocabularyFactory, name='wcc.vocabulary.country') MAPPING = dict([(i['code'], i) for i in COUNTRIES]) def lookup_capital(code): if code in MAPPING: return MAPPING[code]['capital']
def create_new_connection(self): registry = queryUtility(IRegistry) settings = registry.forInterface(IMAXUISettings, check=False) logger.info('Created new MAX connection from domain: {}'.format( settings.domain)) self._conn = (MaxClient(url=settings.max_server, oauth_server=settings.oauth_server), settings) @property def connection(self): self.create_new_connection() return self._conn grok.global_utility(MAXClient) class HUBClient(object): """ The utility will return a tuple with the settings and an instance of a HubClient (REST-ish) object. """ grok.implements(IHubClient) def __init__(self): self._conn = None def __call__(self): return self.connection def create_new_connection(self):
from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary class AvailableLayoutsVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) settings = registry.forInterface(ICoverSettings) items = [SimpleTerm(value=i, title=i) for i in settings.layouts] return SimpleVocabulary(items) grok.global_utility(AvailableLayoutsVocabulary, name=u'collective.cover.AvailableLayouts') class AvailableTilesVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) tiles = registry['collective.cover.controlpanel.ICoverSettings.available_tiles'] items = [SimpleTerm(value=i, title=i) for i in tiles] return SimpleVocabulary(items) grok.global_utility(AvailableTilesVocabulary, name=u'collective.cover.AvailableTiles')
# -*- coding: utf-8 -*- from five import grok from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.interface import implements from Products.CMFCore.utils import getToolByName from mpdg.govbr.faleconosco.interfaces import IAssunto class Assuntos(object): implements(IVocabularyFactory) def __call__(self, context=None): catalog = getToolByName(context, 'portal_catalog') assuntos = catalog(object_provides=IAssunto.__identifier__) itens = [] for brain in assuntos: itens.append(SimpleTerm(value=brain.id, title=brain.Title)) return SimpleVocabulary(itens) grok.global_utility(Assuntos, name=u'mpdg.govbr.faleconosco.Assuntos')
card = token, description = description, **kwargs ) return res def create_customer(self, token, description, context=None, **kwargs): settings = get_settings() stripe = self.get_stripe_api(context=context) res = stripe.Customer.create( card = token, description = description, **kwargs ) return res def subscribe_customer(self, customer_id, plan, quantity, context=None, **kwargs): settings = get_settings() stripe = self.get_stripe_api(context=context) cu = stripe.Customer.retrieve(customer_id) res = cu.update_subscription( plan=plan, quantity=quantity, **kwargs ) return res grok.global_utility(StripeUtility, provides=IStripeUtility)
class MSVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): pvoc = api.portal.get_tool('portal_vocabularies') voc = pvoc.getVocabularyByName('eea_member_states') terms = [] if voc is not None: for key, value in voc.getVocabularyLines(): # create a term - the arguments are the value, the token, and # the title (optional) terms.append(SimpleVocabulary.createTerm(key, key, value)) return SimpleVocabulary(terms) grok.global_utility(MSVocabulary, name=u"esdrt.content.eea_member_states") class GHGSourceCategory(object): grok.implements(IVocabularyFactory) def __call__(self, context): pvoc = api.portal.get_tool('portal_vocabularies') voc = pvoc.getVocabularyByName('ghg_source_category') terms = [] if voc is not None: for key, value in voc.getVocabularyLines(): # create a term - the arguments are the value, the token, and # the title (optional) terms.append(SimpleVocabulary.createTerm(key, key, value)) return SimpleVocabulary(terms)
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from five import grok from zope.schema.interfaces import IVocabularyFactory from incf.countryutils import data as countrydata class TShirtSize(object): def __call__(self, context): return SimpleVocabulary.fromValues( ['S', 'M', 'L', 'XL', 'XXL', 'XXXL'] ) grok.global_utility(TShirtSize, IVocabularyFactory, name="collective.conference.vocabulary.tshirtsize") class Countries(object): def __call__(self, context): return SimpleVocabulary.fromValues(sorted([ i.decode('utf-8') for i,c in countrydata.cn_to_ccn.items() if c != '248' ])) grok.global_utility(Countries, IVocabularyFactory, name="collective.conference.vocabulary.countries") class SessionTypes(object): def __call__(self, context): return SimpleVocabulary.fromValues([ u'Talk',
from five import grok from zope.schema.interfaces import IContextSourceBinder from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.component import getUtility from z3c.formwidget.query.interfaces import IQuerySource VALUES = [ 'HQ', 'Asia', 'Africa', 'Americas', 'Arab States', 'Europe', ] class VocabularyFactory(object): def __call__(self, context): VALUES.sort() terms = [ SimpleTerm(value=pair, token=pair, title=pair) for pair in VALUES ] return SimpleVocabulary(terms) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='ilo.vocabulary.regions')
'Industrial Relations', 'IT Services', 'Labour Law', 'Labour Inspection and Administration', 'Labour Migration', 'Labour Standards', 'Management Services', 'Maritime Labour Convention', 'Millennium Development Goals', 'Programming, M&E', 'Rural Development', 'Safety and Health at Work', 'Skills, Knowledge and Employability', 'Social Security', 'Tripartism and Social Dialogue', 'Workers\' Activities', 'Working Conditions', 'Youth Employment', 'Other', ] class VocabularyFactory(object): def __call__(self, context): return SimpleVocabulary.fromValues(themes) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='ilo.vocabulary.themes')
""" grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) settings = registry.forInterface(IConteudoSettings) areas = settings.area_tematica if areas is not None: termos = [SimpleTerm(unicodedata.normalize('NFKD', area).encode('ascii', 'ignore').lower(), unicodedata.normalize('NFKD', area).encode('ascii', 'ignore').lower(), area) for area in areas] else: termos = [] return SimpleVocabulary(termos) grok.global_utility(AreasTematicas, name=u"observatorio.conteudo.areas_tematicas") class EixoAtuacao(object): """ vocabulario que retorna os eixos de atuacao """ grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) settings = registry.forInterface(IConteudoSettings) eixos = settings.eixo_atuacao if eixos is not None: termos = [SimpleTerm(unicodedata.normalize('NFKD', eixo).encode('ascii', 'ignore').lower(), unicodedata.normalize('NFKD', eixo).encode('ascii', 'ignore').lower(), eixo) for eixo in eixos]
SimpleTerm(value="live", title=u"Live (Production Mode)"), SimpleTerm( value="test", title=u"Test (Test Mode, no transactions really go through, be careful)" ), )) class StripeModesVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): return MODE_VOCABULARY grok.global_utility(StripeModesVocabulary, name=u"collective.stripe.modes") CURRENCY_VOCABULARY = SimpleVocabulary((SimpleTerm(value="usd", title=u"USD - $"), )) class IStripeSettings(Interface): """ Global settings for collective.stripe stored in the registry """ mode = schema.Choice( title=u"Mode", description= u"Determines whether calls to the Stripe API are made using the Test or the Live key", vocabulary=MODE_VOCABULARY, default=u"test", ) test_secret_key = schema.TextLine(
path = collection.getPath() title = collection.Title items.append(SimpleVocabulary.createTerm(path, path, title)) return SimpleVocabulary(items) def isPlone42(self): try: site = getSite() migrationTool = getToolByName(site, 'portal_migration') versions = migrationTool.coreVersions()['Plone'].split('.') return versions[0]=='4' and versions[1]=='2' except: return False grok.global_utility(NewsSourcesVocabulary, name=u'collective.newsticker.NewsSources') class NewsTickerSettingsEditForm(controlpanel.RegistryEditForm): schema = INewsTickerSettings label = _(u'News Ticker Settings') description = _(u'Here you can modify the settings for ' 'collective.newsticker.') def updateFields(self): super(NewsTickerSettingsEditForm, self).updateFields() def updateWidgets(self): super(NewsTickerSettingsEditForm, self).updateWidgets()
cats = catalog.uniqueValuesFor("category") entries = [] done = [] for cat in cats: cat_unicode = safe_unicode(cat) cat_id = idnormalizer.normalize(cat_unicode) if cat_id not in done: entry = (cat_id, cat_unicode) entries.append(entry) done.append(cat_id) terms = [SimpleTerm(value=pair[0], token=pair[0], title=pair[1]) for pair in entries] return SimpleVocabulary(terms) grok.global_utility(ShopCategoriesVocabulary, name=u"chromsystems.shopcontent.ShopCategories") def editbar_actions(): actions = { 'editbar-quit': _(u"Quit Shop Editor"), 'editbar-add': _(u"Add"), 'editbar-edit': _(u"Edit"), 'editbar-preview': _(u"Preview"), 'editbar-delete': _(u"Delete"), 'editbar-parent': _(u"Go to parent"), 'editbar-categorization': _(u"Categorization"), 'editbar-keywords': _(u"Keywords"), 'editbar-layout': _(u"Layout"), 'editbar-items': _(u"Orderable Items"), 'editbar-state': _(u"State"),
from five import grok from optilux.policy.interfaces import IChannel from zope.interface import implements class Channel(object): grok.implements(IChannel) def __init__(self, port): self.port = port def transmit(self, source, destination, message): print "Sending", message, "from", source,\ "to", destination, "on", self.port http = Channel(80) grok.global_utility(http, provides=IChannel, name="http", direct=True) grok.global_utility(Channel(21), provides=IChannel, direct=True)
class AvailableLayoutsVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) settings = registry.forInterface(ICoverSettings) items = [ SimpleTerm(value=i, title=i) for i in sorted(settings.layouts) ] return SimpleVocabulary(items) grok.global_utility(AvailableLayoutsVocabulary, name=u'collective.cover.AvailableLayouts') class AvailableTilesVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) tiles = registry[ 'collective.cover.controlpanel.ICoverSettings.available_tiles'] items = [SimpleTerm(value=i, title=i) for i in tiles] return SimpleVocabulary(items)
titulacio_en = schema.TextLine(title=_(u'Titulacions EN'), description=_(u''), required=False) class EnrollVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): types = [] types.append(SimpleVocabulary.createTerm(u'I', 'I', _(u'Enroll'))) types.append(SimpleVocabulary.createTerm(u'R', 'R', _(u'Register'))) return SimpleVocabulary(types) grok.global_utility(EnrollVocabulary, name=u"genweb.tfemarket.Enrolls") class AllLanguageVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): languages = [] languages.append(SimpleVocabulary.createTerm(u'CA', 'CA', _(u'CA'))) languages.append(SimpleVocabulary.createTerm(u'ES', 'ES', _(u'ES'))) languages.append(SimpleVocabulary.createTerm(u'EN', 'EN', _(u'EN'))) languages.append(SimpleVocabulary.createTerm(u'FR', 'FR', _(u'FR'))) return SimpleVocabulary(languages) grok.global_utility(AllLanguageVocabulary,
catalog['wop_platforms'] = CatalogTextIndex(wop_platforms) wop_programs = NodeAttributeIndexer('wop_programs') catalog['wop_programs'] = CatalogTextIndex(wop_programs) wop_partners = NodeAttributeIndexer('wop_partners') catalog['wop_partners'] = CatalogTextIndex(wop_partners) country = NodeAttributeIndexer('country') catalog['country'] = CatalogTextIndex(country) position = NodeAttributeIndexer('position') catalog['position'] = CatalogTextIndex(position) type_of_organization = NodeAttributeIndexer('type_of_organization') catalog['type_of_organization'] = CatalogTextIndex(type_of_organization) common_working_areas = NodeAttributeIndexer('common_working_areas') catalog['common_working_areas'] = CatalogTextIndex(common_working_areas) donors = NodeAttributeIndexer('donors') catalog['donors'] = CatalogTextIndex(donors) other_info = NodeAttributeIndexer('other_info') catalog['other_info'] = CatalogTextIndex(other_info) return catalog grok.global_utility(UserPropertiesSoupCatalogFactory, name='user_properties')
} }}, 'size': 1000}) shared_items = [a['_source'] for a in shared_items['hits']['hits']] # Tha is_shared is still required? results = [format_item(a) for a in shared_items if is_shared(a)] # Ordena els resultats per title results.sort(key=lambda a: a['title'].lower()) return results grok.global_utility(ElasticSharing) class SharedWithMe(grok.View): grok.context(Interface) grok.name('shared_with_me') grok.require('genweb.authenticated') grok.layer(IUlearnTheme) def render(self): """ AJAX view to access shared items of the current logged in user """ self.request.response.setHeader('Content-type', 'application/json') results = [] sharing = queryUtility(IElasticSharing)
CLASSIFICATION_UNPROTECTED = u'unprotected' CLASSIFICATION_CONFIDENTIAL = u'confidential' CLASSIFICATION_CLASSIFIED = u'classified' CLASSIFICATION_OPTIONS = ( # Option- # Option Name # level # (1, CLASSIFICATION_UNPROTECTED), (2, CLASSIFICATION_CONFIDENTIAL), (3, CLASSIFICATION_CLASSIFIED), ) grok.global_utility( utils.create_restricted_vocabulary( IClassification['classification'], CLASSIFICATION_OPTIONS, message_factory=_), provides=schema.interfaces.IVocabularyFactory, name=u'classification_classification_vocabulary') form.default_value(field=IClassification['classification'])( utils.set_default_with_acquisition( field=IClassification['classification'], default=CLASSIFICATION_UNPROTECTED ) ) # PUBLIC: Vocabulary and default value PUBLIC_TRIAL_UNCHECKED = u'unchecked'
'CO - Bangkok', 'CO - Beijing', 'CO - Colombo', 'CO - Dhaka', 'CO - Hanoi', 'CO - Islamabad', 'CO - Jakarta', 'CO - Kathmandu', 'CO - Manila', 'CO - Suva', 'DWT - New Delhi', 'CO - New Delhi', 'DWT - Bangkok', 'ILO - Dili', 'ILO - Kabul', 'ILO - Phnom Penh', 'ILO - Tokyo', 'ILO - Vientiane', 'ILO - Yangon', 'HQ', 'ITC Turin', 'Other Regions', ] class VocabularyFactory(object): def __call__(self, context): return SimpleVocabulary.fromValues(offices) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='ilo.vocabulary.offices')
terms = [] types = { 'csv': _('Csv'), 'xml': _('Xml'), 'ical': _('Ical'), 'json': _('json'), } if not self.export: del types['ical'] for term in types: terms.append(SimpleVocabulary.createTerm (term, term, types[term])) return SimpleVocabulary(terms) class EvImportFormats(EvFormats): export = False grok.global_utility(EvFormats, name=u"lev_formats") grok.global_utility(EvImportFormats, name=u"lev_formats_imp") class IEventsCollection(Interface): """Marker interface for views""" class IEventsSearch(Interface): def search(**kwargs): """ search for events"""
grok.implements(IVocabularyFactory) def __call__(self, context): t = lambda txt: translate(txt, context=api.portal.get().REQUEST) types = {t(_('OiRA Tool')).encode('utf-8'): 'tool'} if ISectorContainer.providedBy(context): types.update({ t(_('EU-OSHA Overview')).encode('utf-8'): 'overview', t(_('Country')): 'country' }) elif ICountry.providedBy(context): types.update({t(_('Country')).encode('utf-8'): 'country'}) return SimpleVocabulary.fromItems(types.items()) grok.global_utility(ReportTypeVocabulary, name='osha.oira.report_type') class ReportYearVocabulary(object): """ """ grok.implements(IVocabularyFactory) def __call__(self, context): return SimpleVocabulary.fromValues(range(datetime.now().year, 2010, -1)) grok.global_utility(ReportYearVocabulary, name='osha.oira.report_year') class ReportPeriodVocabulary(object):
from z3c.formwidget.query.interfaces import IQuerySource VALUES = ['Book', 'Report', 'Working paper', 'Discussion paper', 'Other'] NONOFFICIALPUB_VALUES = ['Book', 'Report', 'Other'] WORKINGPAPERPUBTYPE_VALUES = ['Working paper', 'Discussion paper', 'Other'] class VocabularyFactory(object): def __call__(self, context): return SimpleVocabulary.fromValues(sorted(VALUES)) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='ilo.vocabulary.publicationtypes') class NonOfficialPubTypeVocabularyFactory(object): def __call__(self, context): return SimpleVocabulary.fromValues(NONOFFICIALPUB_VALUES) grok.global_utility( NonOfficialPubTypeVocabularyFactory, IVocabularyFactory, name='ilo.vocabulary.publicationtypes.nonofficialpublication') class WorkingPaperPubTypeVocabularyFactory(object):
def __call__(self, context): TYPES = {_(u'Seniors'): 'seniors', _(u'Sport'): 'sport', _(u'Education and Job'): 'education', _(u"Neighborhood"): 'neighborhood', _(u"Social"): 'social', _(u"Culture and Arts"): 'culture', _(u"Services"): 'services', _(u"Youth"): 'youth', _(u"Family"): 'family'} return SimpleVocabulary([SimpleTerm(value, title=title) for title, value in TYPES.iteritems()]) grok.global_utility(InstitutionTypeVocabulary, name=u"amap.mapview.InstitutionTypes") def color_codes(): codes = dict({'seniors': u'#4a5f21', 'sport': u'#910f1e', 'education': u'#97be0d', 'neighborhood': u"#584e98", 'social': u"#f8b334", 'culture': u"#92117e", 'services': u"#dd0b1a", 'youth': u"#025e5c", 'family': u"#dd6aa2"}) return codes
from five import grok from zope.schema.interfaces import IContextSourceBinder from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.component import getUtility from z3c.formwidget.query.interfaces import IQuerySource SCHEMES_CSS={ 'red': 'wcc-waterscheme-red.css', 'blue': 'wcc-waterscheme-blue.css', 'darkgreen': 'wcc-waterscheme-darkgreen.css' } class ColorSchemes(object): def __call__(self, context): return SimpleVocabulary.fromValues(SCHEMES_CSS.keys()) grok.global_utility(ColorSchemes, IVocabularyFactory, name='wcc.watertheme.colorscheme')
from collective.cover.controlpanel import ICoverSettings class AvailableLayoutsVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) settings = registry.forInterface(ICoverSettings) items = [SimpleTerm(value=i, title=i) for i in settings.layouts] return SimpleVocabulary(items) grok.global_utility(AvailableLayoutsVocabulary, name=u'collective.cover.AvailableLayouts') class AvailableTilesVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) tiles = registry['plone.app.tiles'] # TODO: verify the tile implements IPersistentCoverTile items = [SimpleTerm(value=i, title=i) for i in tiles] return SimpleVocabulary(items)
from jobtool.jobcontent import MessageFactory as _ class JobTypeVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): TYPES = {_(u"Fulltime"): 'fulltime', _(u"Parttime"): 'parttime', _(u"Fulltime and Parttime"): 'fullandpart'} return SimpleVocabulary([SimpleTerm(value, title=title) for title, value in TYPES.iteritems()]) grok.global_utility(JobTypeVocabulary, name=u"jobtool.jobcontent.jobTypes") class JobCategoryVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): CATS = {_(u"Education"): 'education', _(u"Psychology"): 'psychology', _(u"Administration"): 'administration', _(u"Care"): 'care', _(u"Medicine"): 'medicine', _(u"Internship"): 'internship', _(u"Other"): 'other' }
from five import grok from zope.schema.interfaces import IContextSourceBinder from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.component import getUtility from z3c.formwidget.query.interfaces import IQuerySource from eea.faceted.vocabularies.catalog import CatalogIndexesVocabulary class document_sort(CatalogIndexesVocabulary): def __call__(self, context): """ See IVocabularyFactory interface """ indexes = ['sortable_title', 'effective', 'document_owner', 'document_type'] return self._create_vocabulary(context, indexes) grok.global_utility(document_sort, name="wcc.document.document_sort")
class Localizzazioni(object): grok.implements(IVocabularyFactory) def __call__(self, context): terms = [] for term in ['Area boschiva', 'Area collinare','Area industriale', 'Area marina e costiera', 'Area montana', 'Area periferica', 'Area protetta', 'Area residenziale', 'Area rurale', 'Area turistica', 'Area umida', 'Area urbana', 'Centro Storico', 'Territorio provinciale', 'Territorio regionale', 'Territorio nazionale']: terms.append(SimpleTerm(unicode(term, "utf-8", errors="ignore"), unicode(term, "utf-8", errors="ignore"))) return SimpleVocabulary(terms) grok.global_utility(Localizzazioni, name=u"localizzazioni") class Ambiti(object): grok.implements(IVocabularyFactory) def __call__(self, context): terms = [] for term in ['Ambito nazionale', 'Area Marina Protetta', 'Associazione', 'Autorità di bacino', 'Comune', 'Comuni (più di uno)', 'Comunità montana', 'Distretto industriale', 'G.A.L. gruppo di azione locale', 'Parco Nazionale', 'Parco Regionale', 'Provincia', 'Regione', 'Riserva Naturale Statale o Regionale', 'Scuola']: token=idnormalizer.normalize(term) terms.append(SimpleVocabulary.createTerm(term, token, term)) return SimpleVocabulary(terms)
from five import grok from zope.component import getUtility from zope import schema from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleVocabulary from collective.stripe.utils import IStripeUtility class StripePlansVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): return self.get_plans(context) def get_plans(self, context): api = getUtility(IStripeUtility).get_stripe_api(context) terms = [] for info in api.Plan.all()['data']: name = '%s (per %s)' % (info['name'], info['interval']) terms.append(SimpleVocabulary.createTerm(info['id'], info['id'], name)) return SimpleVocabulary(terms) grok.global_utility(StripePlansVocabulary, name=u"collective.stripe.plans")
'title': 'Judaism', 'follower': 'Jews' }, { 'id': 'african-traditional', 'title': 'African Traditional', 'follower': 'African Traditional' }, { 'id': 'other', 'title': 'Other', 'follower': 'Other' } ] class VocabularyFactory(object): def __call__(self, context): terms = [SimpleTerm(value=i['id'], title=i['title']) for i in RELIGIONS] return SimpleVocabulary(terms) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='wcc.vocabulary.religion') class FollowerVocabularyFactory(object): def __call__(self, context): terms = [SimpleTerm(value=i['id'], title=i['follower']) for i in RELIGIONS] return SimpleVocabulary(terms) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='wcc.vocabulary.religionfollower')
from five import grok from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary from zope.schema.interfaces import IVocabularyFactory from hph.sitecontent import MessageFactory as _ class ThirdPartyProjectsVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): TYPES = { _(u"Rottendorf Project"): 'rottendorf', _(u"Philosophy and Motivation"): 'motivation', _(u"Philosophy and Leadership"): 'leadership', _(u"IGP"): 'igp', _(u"Mediaethics"): 'mediaethics', } return SimpleVocabulary([SimpleTerm(value, title=title) for title, value in TYPES.iteritems()]) grok.global_utility(ThirdPartyProjectsVocabulary, name=u"hph.sitecontent.thirdPartyProjects")
from five import grok from zope.schema.interfaces import IContextSourceBinder from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.schema.interfaces import IVocabularyFactory from zope.component import getUtility from z3c.formwidget.query.interfaces import IQuerySource import pycountry CLASSIFICATIONS = [ { 'id': 'developing-country', 'title': 'Developing Country' }, ] class VocabularyFactory(object): def __call__(self, context): terms = [ SimpleTerm(value=i['id'], title=i['title']) for i in CLASSIFICATIONS ] return SimpleVocabulary(terms) grok.global_utility(VocabularyFactory, IVocabularyFactory, name='wcc.vocabulary.classification')
from silva.translations import translate as _ from zeam.form import silva as silvaforms from OFS.Image import Image as ZopeImage class PreviewResolution(object): grok.implements(IPreviewResolution) def __init__(self, title, resolution): self.title = title self.resolution = resolution grok.global_utility( PreviewResolution, provides=IFactory, name=IPreviewResolution.__identifier__, direct=True) class UIService(SilvaService): meta_type = 'Silva SMI Service' grok.implements(IUIService) grok.name('service_ui') silvaconf.default_service() silvaconf.icon('service.png') manage_options = ( {'label': 'SMI Generic settings', 'action': 'manage_settings'}, {'label': 'SMI Folder settings',
class VirtualHost(object): grok.implements(interfaces.IVirtualHost) def __init__(self, url, aliases, rewrites): self.url = to_url(url) self.aliases = map(to_url, aliases) self.rewrites = rewrites def build(self, root): for url in [self.url] + self.aliases: yield VirtualHostRule(root, url, self.rewrites) grok.global_utility( Rewrite, provides=IFactory, name=interfaces.IRewrite.__identifier__, direct=True) grok.global_utility( VirtualHost, provides=IFactory, name=interfaces.IVirtualHost.__identifier__, direct=True) class ForestManageSettings(silvaforms.ZMIComposedForm): grok.name('manage_settings') grok.context(ForestService) label = _(u"Forest Service configuration")
from five import grok from zope.component import getUtility from zope import schema from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleVocabulary from collective.stripe.utils import IStripeUtility class StripePlansVocabulary(object): grok.implements(IVocabularyFactory) def __call__(self, context): return self.get_plans(context) def get_plans(self, context): api = getUtility(IStripeUtility).get_stripe_api(context) terms = [] for info in api.Plan.all()['data']: name = '%s (per %s)' % (info['name'], info['interval']) terms.append( SimpleVocabulary.createTerm(info['id'], info['id'], name)) return SimpleVocabulary(terms) grok.global_utility(StripePlansVocabulary, name=u"collective.stripe.plans")