def __call__(self, context): while True: if IBlog.providedBy(context): break if IDraftContent.providedBy(context): context = context.getLocation() if ISpace.providedBy(context): context = context.get('blog') break context = getattr(context, '__parent__', None) if context is None: break if context is None: return SimpleVocabulary(()) ids = getUtility(IIntIds) categories = [] for category in context['category'].values(): try: id = ids.getId(removeAllProxies(category)) except: continue term = SimpleTerm(id, str(id), category.title) term.description = category.description categories.append((category.title, term)) categories.sort() return SimpleVocabulary([term for title, term in categories])
def __call__(self, context): while True: if IProject.providedBy(context): break if IDraftContent.providedBy(context): context = context.getLocation() if not ITasks.providedBy(context): context = None context = getattr(context, '__parent__', None) break context = getattr(context, '__parent__', None) if context is None: break if context is not None: context = context.get('tasks') if context is None: return SimpleVocabulary(()) ids = getUtility(IIntIds) categories = [] for category in context.category.values(): id = ids.getId(removeAllProxies(category)) term = SimpleTerm(id, str(id), category.title) term.description = category.description categories.append((category.title, term)) categories.sort() return SimpleVocabulary([term for title, term in categories])
def __init__(self, types): terms = [] for type in types: term = SimpleTerm(type, type.name, type.title) term.name = type.name term.description = type.description terms.append(term) super(InformationTypeVocabulary, self).__init__(terms)
def GlobalKeysVocabulary(context): terms = [] for key in GLOBAL_KEYS.values(): term = SimpleTerm(key.name, key.name, key.title) term.description = key.description terms.append((key.title, term)) terms.sort() return SimpleVocabulary([term for _t, term in terms])
def __call__(self, context): terms = [] for layer, info in tool.layers_registry.items(): term = SimpleTerm(info[1], info[1], info[2]) term.description = info[3] terms.append((info[2], info[1], term)) terms.sort() return Vocabulary([term for title, name, term in terms])
def ActivityRecordDescriptions(context): terms = [] for name, desc in getUtilitiesFor(IActivityRecordDescription): term = SimpleTerm(name, name, desc.title) term.description = desc.description terms.append((desc.title, name, term)) terms.sort() return SimpleVocabulary([term for t, n, term in terms])
def __call__(self, context): if not IDraftContent.providedBy(context): return Vocabulary(()) ct = IContentType(context) types = [] for tp in ct.destination: types.append(tp.name) kwargs = {} if types: kwargs['type'] = {'any_of': types} request = getRequest() catalog = getUtility(ICatalog) perms = {} permissions = [] for id in listAllowedRoles(request.principal, context): perms[ct.submit] = 1 perms[ct.publish] = 1 permissions.append((ct.submit, id)) permissions.append((ct.publish, id)) results = catalog.searchResults( draftSubmitTo={'any_of': permissions}, **kwargs) if not results: return Vocabulary(()) perms = perms.keys() ids = getUtility(IIntIds) contents = [] for content in results: allow = False for perm in perms: if checkPermission(perm, content): allow = True break if allow: contents.append( (getPath(content), IItem(content).title, ids.getId(content), content)) contents.sort() terms = [] for path, title, id, content in contents: term = SimpleTerm( id, str(id), getMultiAdapter((content, request), IBreadcrumb)) term.content = content terms.append(term) return Vocabulary(terms)
def __call__(self, context): wfs = [] for name, wf in getAdapters((PersonalSpace(),), IWorkspaceFactory): if not IInactiveWorkspaceFactory.providedBy(wf): term = SimpleTerm(name, name, wf.title) term.description = wf.description wfs.append((wf.weight, wf.title, term)) wfs.sort() return Vocabulary([term for _w, _t, term in wfs])
def __call__(self, context, **kw): roles = [] for name, role in getUtilitiesFor(IPublicRole): if role.title != 'Site Manager' and not role.id: continue term = SimpleTerm(role.id, role.id, role.title) term.description = getattr(role, 'description', u'') roles.append((role.title, term)) roles.sort() return Vocabulary([term for title, term in roles])
def SessionFactories(context): terms = [] for name, factory in getUtilitiesFor(ISessionDataFactory): if not factory.isAvailable(): continue term = SimpleTerm(name, name, factory.title) term.description = factory.description terms.append((factory.title, name, term)) terms.sort() return SimpleVocabulary([term for _t, _n, term in terms])
def _term_generator(self, reg): for record in reg[self.__name__]: term = SimpleTerm(value=record['value'], token=record['value'], title=record['title']) # attach additional attributes to term: for key in record.keys(): if not hasattr(term, key): if not hasattr(term, 'data'): term.data = {} term.data[key] = record[key] yield term
def __call__(self, context): configlet = getUtility(IContentFeaturedConfiglet) terms = [] keys = [] for name, ct in configlet.listFeaturableContentTypes(): term = SimpleTerm(ct.name, ct.name, ct.title) term.description = ct.description if ct.name in keys: continue terms.append((ct.title, ct.name, term)) keys.append(ct.name) terms.sort() return Vocabulary([term for t,n,term in terms])
def WorkflowStates(content): wf = IWorkflow(content, None) if wf is None: return SimpleVocabulary(()) terms = [] for state in wf.getStates(): term = SimpleTerm(state.id, state.id, state.title) term.state = state.description terms.append((state.title, term)) terms.sort() return SimpleVocabulary([term for _t, term in terms])
def WorkflowTransitions(content): wfinfo = IWorkflowInfo(content, None) if wfinfo is None: return SimpleVocabulary(()) terms = [] for transition in wfinfo.getTransitions(): term = SimpleTerm(transition.id, transition.id, transition.title) term.description = transition.description terms.append((transition.title, term)) terms.sort() return SimpleVocabulary([term for _t, term in terms])
def PortalCategoryIdsVocabulary(context=None): result = getUtility(ICatalog).searchResults( type={'any_of': ('contenttype.newsitem.category', )}) getObject = result.uidutil.getObject terms = [] for uid in result.uids: category = getObject(uid) term = SimpleTerm(uid, str(uid), category.title) term.description = category.description terms.append((term.title, term)) terms.sort() return SimpleVocabulary([term for _t, term in terms])
def PortalCategoryIdsVocabulary(context=None): result = getUtility(ICatalog).searchResults(type={'any_of': ('contenttype.media.category', )}) getObject = result.uidutil.getObject terms = [] for uid in result.uids: category = getObject(uid) term = SimpleTerm(uid, str(uid), category.title) term.description = category.description terms.append(term) terms.sort(key=lambda t:t.title) return SimpleVocabulary(terms)
def __call__(self, context): request = getRequest() if request is None: return SimpleVocabulary(()) results = getUtility(ICatalog).searchResults( type = {'any_of': ('content.group',)}, members = {'any_of': (request.principal.id,)}) groups = [] for group in results: term = SimpleTerm(group.id, str(group.id), group.title) term.description = group.description groups.append((group.title, term)) groups.sort() return SimpleVocabulary([term for _t, term in groups])
def tipology2term(self, idx, tipology): ''' return a vocabulary tern with this ''' idx = str(idx) name = tipology.get('name', '') if isinstance(name, str): name = name.decode('utf8') duration = tipology.get('duration', '') if isinstance(duration, str): duration = duration.decode('utf8') if not duration: title = name else: title = u"%s (%s min)" % (name, duration) # fix for buggy implementation term = SimpleTerm(name, token='changeme', title=title) term.token = name return term
def CategoryIdsVocabulary(context): while True: if ISpace.providedBy(context): break if IDraftContent.providedBy(context): context = context.getLocation() break context = getattr(context, '__parent__', None) if context is None: break if context is None: return SimpleVocabulary(()) getId = getUtility(IIntIds).getId terms = [] while True: ws = queryAdapter(context, IWorkspaceFactory, name='media') if ws is not None and ws.isInstalled(): for category in context['media']['category'].values(): id = getId(removeAllProxies(category)) term = SimpleTerm(id, str(id), category.title) term.description = category.description terms.append(term) if IPortal.providedBy(context): break context = getattr(context, '__parent__', None) if context is None or not ISpace.providedBy(context): break terms.sort(key=lambda t:t.title) return SimpleVocabulary(terms)
def CategoryIdsVocabulary(context): while True: if ISpace.providedBy(context): break if IDraftContent.providedBy(context): context = context.getLocation() if context is not None: context = context.__parent__ break context = getattr(context, '__parent__', None) if context is None: break if context is None: return SimpleVocabulary(()) getId = getUtility(IIntIds).getId terms = [] while True: wf = queryAdapter(context, IWorkspaceFactory, name='news') if wf is not None and wf.isInstalled(): for category in context['news']['category'].values(): id = getId(removeAllProxies(category)) term = SimpleTerm(id, str(id), category.title) term.description = category.description terms.append((term.title, term)) if ISite.providedBy(context): break context = getattr(context, '__parent__', None) if context is None or not ISpace.providedBy(context): break terms.sort() return SimpleVocabulary([term for _t, term in terms])
def __call__(self, context): configlet = getUtility(IContentTaggingConfiglet) engines = {} for engine in configlet.contentTypesEngines(): engines[engine.__name__] = engine for name, engine in configlet.items(): if name not in engines and name != 'global': engines[name] = engine terms = [] for name, engine in engines.items(): term = SimpleTerm(name, name, engine.title) term.description = engine.description terms.append((engine.title, name, term)) terms.sort() engine = configlet.globalEngine default = SimpleTerm('global', 'global', engine.title) default.description = engine.description return Vocabulary([default] + [term for t,n,term in terms])
def __call__(self, context): while not IContent.providedBy(context): context = getattr(context, '__parent__', None) if context is None: return SimpleVocabulary(()) try: request = getInteraction().participations[0] except: request = TestRequest() terms = [] for name, view in getAdapters((context, request), IViewModel): view.update() if not view.isAvailable(): continue term = SimpleTerm(name, name, view.__title__) term.description = view.__description__ terms.append((view.__title__, term)) terms.sort() return Vocabulary([defaultModel] + [term for t, term in terms])
def __call__(self, context): control_panel = api.portal.get_tool('portal_types') all_portaltypes = control_panel.listContentTypes() vocabulary = SimpleVocabulary( [SimpleTerm(p, p, p) for p in all_portaltypes]) return vocabulary
def test_context_vocabulary_factory(context): return SimpleVocabulary([ SimpleTerm(context.id, token="id", title=context.id), SimpleTerm(context.title, token="title", title=context.title), ])
def __call__(self, context): session = Session() query = session.query(db.UF).order_by(db.UF.nome).all() return SimpleVocabulary([SimpleTerm(a.id, a.id, a.nome) for a in query])
def update(self): session = Session() query = session.query(db.Protocolo).order_by(db.Protocolo.numero).all() return SimpleVocabulary([SimpleTerm(p.id, p.id, p.numero) for p in query])
class IEmbedder(model.Schema): """ A representation of a content embedder content type """ form.order_before(**{'url': '*'}) url = schema.ASCIILine( title=_(u'Multimedia URL'), description=_(u'The URL for your multimedia file. Can be a URL ' + u'from YouTube, Vimeo, SlideShare, SoundCloud or ' + u'other main multimedia websites.'), required=False, ) width = schema.ASCIILine( title=_(u'Width'), description= _(u'Can be expressed as a decimal number or a percentage, e.g., 270 or 50%.' ), required=True, constraint=validate_int_or_percentage, ) height = schema.Int( title=_(u'Height'), description=_(u'Can be expressed as a decimal number, e.g., 480.'), required=True, min=1, max=9999, ) embed_html = schema.Text( title=_(u'Embedded HTML code'), description=_(u'HTML code to render the embedded media.'), required=True, ) player_position = schema.Choice(title=_(u'Player position'), description=_(u''), default=u'Top', required=True, vocabulary=SimpleVocabulary([ SimpleTerm(value=u'Top', title=_(u'Top')), SimpleTerm(value=u'Bottom', title=_(u'Bottom')), SimpleTerm(value=u'Left', title=_(u'Left')), SimpleTerm(value=u'Right', title=_(u'Right')) ])) form.widget(image=EmbedderImageFieldWidget) image = NamedImage( title=_(u'Preview image'), description=_(u'Image to be used when listing content.'), required=False, ) text = RichText( title=_(u'Body text'), required=False, ) alternate_content = RichText( title=_(u'Alternate content'), description=_( u'Description or transcription for accessibility (WCAG) users.'), required=False, )
class IECH0147ExportFormSchema(Schema): recipients = schema.List( title=_(u'label_recipients', default=u'Recipient(s)'), description=_(u'help_recipients', default=u'Recipients of the message. Enter one recipient' ' per line.'), value_type=schema.TextLine(), required=False, ) action = schema.Choice( title=_(u'label_action', default=u'Action'), description=_(u'help_action', default=u''), vocabulary=SimpleVocabulary([ SimpleTerm(1, '1', _(u'term_action_1', default=u'new')), SimpleTerm(3, '3', _(u'term_action_3', default=u'revocation')), SimpleTerm(4, '4', _(u'term_action_4', default=u'correction')), SimpleTerm(5, '5', _(u'term_action_5', default=u'inquiry')), SimpleTerm(6, '6', _(u'term_action_6', default=u'response')), SimpleTerm(7, '7', _(u'term_action_7', default=u'key exchange')), SimpleTerm(10, '10', _(u'term_action_10', default=u'forwarding')), SimpleTerm(12, '12', _(u'term_action_12', default=u'reminder')), ]), ) subject = schema.TextLine( title=_(u'label_subject', default=u'Subject'), required=False, ) comment = schema.TextLine( title=_(u'label_comment', default=u'Comment'), required=False, ) directive = schema.Choice( title=_(u'label_directive', default=u'Directive'), description=_(u'help_directive', default=u''), vocabulary=SimpleVocabulary([ SimpleTerm(u'process', 'process', _(u'term_directive_process', default=u'process')), SimpleTerm( u'external_process', 'external_process', _(u'term_directive_external_process', default=u'external process')), SimpleTerm( u'information', 'information', _(u'term_directive_information', default=u'informationrocess')), SimpleTerm(u'comment', 'comment', _(u'term_directive_comment', default=u'comment')), SimpleTerm(u'approve', 'approve', _(u'term_directive_approve', default=u'approve')), SimpleTerm(u'sign', 'sign', _(u'term_directive_sign', default=u'sign')), SimpleTerm(u'send', 'send', _(u'term_directive_send', default=u'send')), SimpleTerm(u'complete', 'complete', _(u'term_directive_complete', default=u'complete')), ]), required=False, ) priority = schema.Choice( title=_(u'label_priority', default=u'Priority'), vocabulary=SimpleVocabulary([ SimpleTerm(u'undefined', 'undefined', _(u'term_priority_undefined', default=u'undefined')), SimpleTerm(u'medium', 'medium', _(u'term_priority_medium', default=u'medium')), SimpleTerm(u'high', 'high', _(u'term_priority_high', default=u'high')), ]), ) directives.widget(deadline=DatePickerFieldWidget) deadline = schema.Date( title=_(u'label_deadline', default=u'Deadline'), required=False, ) directives.mode(paths='hidden') paths = RelationList( title=_(u'label_paths', default=u'Paths'), default=[], missing_value=[], value_type=RelationChoice( title=u"Path", source=SolrObjPathSourceBinder( object_provides=( 'opengever.dossier.behaviors.dossier.IDossierMarker', 'opengever.document.behaviors.IBaseDocument'), navigation_tree_query={ 'object_provides': [ 'opengever.repository.repositoryroot.IRepositoryRoot', 'opengever.repository.interfaces.IRepositoryFolder', 'opengever.dossier.behaviors.dossier.IDossierMarker' ], }), ), required=False, )
def TipoProtocoloVocabulary(context): return SimpleVocabulary([ SimpleTerm('R','R', _(u'Recebido')), SimpleTerm('E','E', _(u'Expedido')), SimpleTerm('I','I', _(u'Interno')), ])
def dummy_source_vocab(self, context): return SimpleVocabulary([ SimpleTerm(value=u"foo", title=u"Foo"), SimpleTerm(value=u"bar", title=u"Bar"), ])
def terms(self): return [ SimpleTerm(value=x, token=x.encode('utf-8'), title=x) for x in self.vocab_name ]
def FormatoEtiquetaVocabulary(context): ret = [] for k, v in FORMATOS_SUPORTADOS.items(): ret.append(SimpleTerm(k, k, _(u'Tipo: %d, Papel: %s, %d linhas x %d colunas (PIMACO: %s)' % ( k, v['Papel'], v['Linhas'], v['Colunas'], v['Codigo'])))) return SimpleVocabulary(ret)
# -*- coding: utf-8 -*- from collective.weather import _ from datetime import timedelta from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary PROJECTNAME = 'collective.weather' COOKIE_KEY = 'collective.weather.%s' # Time that should pass before fetching new weather information. TIME_THRESHOLD = timedelta(minutes=30) UNIT_SYSTEMS = SimpleVocabulary([ SimpleTerm(value=u'metric', title=_(u'Metric')), SimpleTerm(value=u'imperial', title=_(u'Imperial')), ])
def __call__(self, context): session = Session() query = session.query(db.TipoDocumento).order_by(db.TipoDocumento.nome).all() return SimpleVocabulary([SimpleTerm(t.id, t.id, t.nome) for t in query])
def __call__(self, context): session = Session() areas = session.query(db.Area).order_by(db.Area.nome).all() return SimpleVocabulary([SimpleTerm(a.id, a.id, a.nome) for a in areas])
############################################################################## # # Copyright (c) 2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """ $Id$ """ from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary tp1 = SimpleTerm(u'ram', 'ram', 'RAM Cache') tp1.description = u'This cache store data in ram.' tp2 = SimpleTerm(u'memcached', 'memcached', 'Memcached') tp2.description = u'This cache store data in memcached server.' cacheTypes = SimpleVocabulary((tp1, tp2))
from .config import PACKAGE_NAME from Products.CMFCore.utils import getToolByName from plone.dexterity.fti import DexterityFTI from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm, getVocabularyRegistry from zope.component import provideUtility, getGlobalSiteManager, getSiteManager from zope.schema.interfaces import IVocabularyFactory TEST_CONTENT_TYPE_ID = 'TestContentType' VOCABULARY_TUPLES = [ (u'first_value', u'First Title'), (u'second_value', None), ] VOCABULARY = SimpleVocabulary( [SimpleTerm(value=v, title=t) for (v, t) in VOCABULARY_TUPLES]) def vocabulary_factory(context): return VOCABULARY class PackageLayer(PloneSandboxLayer): defaultBases = (PLONE_FIXTURE, ) def setUpZope(self, app, configurationContext): import collective.dexteritydiff import plone.app.dexterity self.loadZCML(package=collective.dexteritydiff) self.loadZCML(package=plone.app.dexterity)
from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID from plone.restapi.testing import PLONE_RESTAPI_DX_FUNCTIONAL_TESTING from plone.restapi.testing import RelativeSession from zope.component import getGlobalSiteManager from zope.component import provideUtility from zope.componentvocabulary.vocabulary import UtilityTerm from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary import six import transaction import unittest TEST_TERM_1 = SimpleTerm(42, token="token1", title=u"Title 1") TEST_TERM_2 = SimpleTerm(43, token="token2", title=u"Title 2") TEST_TERM_3 = SimpleTerm(44, token="token3") TEST_TERM_4 = UtilityTerm(45, "token4") if six.PY2: TEST_TERM_5 = SimpleTerm(46, token="token5", title=u"T\xf6tle 5") TEST_TERM_6 = SimpleTerm(47, token="token6", title="T\xc3\xb6tle 6") else: TEST_TERM_5 = SimpleTerm(46, token="token5", title="Tötle 5") TEST_TERM_6 = SimpleTerm(47, token="token6", title="Tötle 6") TEST_VOCABULARY = SimpleVocabulary([ TEST_TERM_1, TEST_TERM_2, TEST_TERM_3, TEST_TERM_4, TEST_TERM_5, TEST_TERM_6 ])
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zojax.content.type.interfaces import IContent from interfaces import _, IViewModel class Vocabulary(SimpleVocabulary): def getTerm(self, value): try: return self.by_value[value] except KeyError: return self.by_value[self.by_value.keys()[0]] defaultModel = SimpleTerm(u'__default__', '__default__', _('Default')) defaultModel.description = _('Default content item view presentation.') class Models(object): """ >>> from zope import interface, component >>> factory = Models() >>> list(factory(None)) [] >>> from zojax.content.type.item import Item >>> from zojax.extensions.interfaces import IExtension >>> class Content(Item):
grok.order(10) label = _('Edit') ignoreContent = False dataManager = silvaforms.SilvaDataManager fields = silvaforms.Fields(IImageAddFields).omit('id') fields['image'].fileSetLabel = _( "Click the Upload button to replace the current image with a new image." ) actions = silvaforms.Actions(silvaforms.CancelEditAction(), silvaforms.EditAction()) image_formats = SimpleVocabulary([ SimpleTerm(title='jpg', value='JPEG'), SimpleTerm(title='png', value='PNG'), SimpleTerm(title='gif', value='GIF') ]) class IFormatAndScalingFields(Interface): web_format = schema.Choice(source=image_formats, title=_("Web format"), description=_("Image format for web.")) web_scale = schema.TextLine( title=_("Scaling"), description=_('Image scaling for web: use width x ' 'height in pixels, or one axis length, ' 'or a percentage (100x200, 100x*, *x200, 40%).' 'Use 100% to scale back to the orginal format.'),
# FOR A PARTICULAR PURPOSE. # ############################################################################## """ $Id$ """ from zope import component from zope.i18nmessageid import MessageFactory from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary from zope.lifecycleevent.interfaces import IObjectModifiedEvent _ = MessageFactory('zojax.project') tp1 = SimpleTerm('open', 'open', _('Open Project')) tp1.description = _('Membership is open and non-members can view content and participate.') tp2 = SimpleTerm('members', 'members', _('Members Only Project')) tp2.description = _('Membership is open and non-members can ' 'view content, but must join to participate.') tp3 = SimpleTerm('private', 'private', _('Private Project')) tp3.description = _('Membership is by approval/invitation only and only ' 'members can view content and participate.') tp4 = SimpleTerm('secret', 'secret', _('Secret Project')) tp4.description = _('Membership is by invitation only, ' 'only members may participate, and the group ' 'is not listed in the group directory.')
def __call__(self, context): terms = [] for i in self._terms: terms.append(SimpleTerm(*i)) return SimpleVocabulary(terms)
def TipoPessoaVocabulary(context): return SimpleVocabulary([ SimpleTerm('F','F', _(u'Física')), SimpleTerm('O','O', _(u'Organização')), ])
# -*- coding: utf-8 -*- from datetime import timedelta from plone import api from ploneconf.policy.interfaces import IPloneconfPolicySettings from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary PRESENTATION_DURATION_TYPES = SimpleVocabulary( [ SimpleTerm(value=u'Short talk', title=u'Short talk'), SimpleTerm(value=u'Long talk', title=u'Long talk'), ] ) TRAINING_CLASS_DURATION_TYPES = SimpleVocabulary( [ SimpleTerm(value=u'Half day', title=u'1/2 day'), SimpleTerm(value=u'One day', title=u'1 day'), SimpleTerm(value=u'Two days', title=u'2 days'), ] ) TRAINING_CLASS_ROOMS = SimpleVocabulary( [ SimpleTerm(value=u'Dev\'s den', title=u'Dev\'s den'), SimpleTerm(value=u'Pistachio room', title=u'Pistachio room'), SimpleTerm(value=u'Relax room', title=u'Relax room'), SimpleTerm(value=u'10 absents room', title=u'10 absents room'),
def __call__(self, context): session = Session() query = session.query(db.Situacao).order_by(db.Situacao.nome).all() return SimpleVocabulary([SimpleTerm(s.id, s.id, s.nome) for s in query])
from hot.filmes import _ from plone.app.textfield import RichText from plone.autoform import directives from plone.namedfile import field as namedfile from plone.supermodel import model from plone.supermodel.directives import fieldset from z3c.form.browser.radio import RadioFieldWidget from zope import schema from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary LevelVocabulary = SimpleVocabulary( [SimpleTerm(value=u'platinum', title=_(u'Platinum Sponsor')), SimpleTerm(value=u'gold', title=_(u'Gold Sponsor')), SimpleTerm(value=u'silver', title=_(u'Silver Sponsor')), SimpleTerm(value=u'bronze', title=_(u'Bronze Sponsor'))] ) class Iteste(model.Schema): """Dexterity Schema for Sponsors """ directives.widget(level=RadioFieldWidget) level = schema.Choice( title=_(u'Sponsoring Level'), vocabulary=LevelVocabulary, required=True )
def update(self): session = Session() query = session.query(db.Pessoa).order_by(db.Pessoa.nome).all() return SimpleVocabulary([SimpleTerm(p.id, p.id, p.nome) for p in query])
def search(self, query): terms = [SimpleTerm(query, query)] return iter(terms)
from plone import api from plone.indexer.decorator import indexer from plone.app.textfield import RichText from plone.namedfile.field import NamedBlobImage from plone.supermodel import model from zope import schema from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm click_options = SimpleVocabulary([ SimpleTerm(value=u'Do Nothing', title=u'Do Nothing'), SimpleTerm(value=u'Feature Page', title=u'Feature Page'), SimpleTerm(value=u'Use Link', title=u'Use Link'), ]) class IFeature(model.Schema): title = schema.TextLine( title=u"Title", required=True, ) rotation_speed = schema.TextLine( title=u"Rotation Speed (seconds)", required=True, default=u"10", ) # --- Feature One FieldSet --- model.fieldset( 'feature-one',
############################################################################## # # Copyright (c) 2009 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """ $Id$ """ from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary tp1 = SimpleTerm(u'upload', 'upload', 'On Upload (Best Performance)') tp1.description = u'This creates preview when you add or modify file.' tp2 = SimpleTerm(u'check', 'check', 'Always if doesn\'t exist') tp2.description = u'This checks that preview is available and creates it in opposite case.' tp3 = SimpleTerm(u'always', 'always', 'Always') tp3.description = u'This generates preview every time when it\'s requested.' creationTypes = SimpleVocabulary((tp1, tp2, tp3))
def __call__(self, context): vocabulary = SimpleVocabulary([ SimpleTerm(pod_format, pod_format, label) for pod_format, label in POD_FORMATS ]) return vocabulary
def __call__(self, context): items = [] for country in pycountry.countries: items.append(SimpleTerm(country.alpha2, country.alpha2, country.name)) return SimpleVocabulary(items)
def __call__(self, context): # Just an example list of content for our vocabulary, # this can be any static or dynamic data, a catalog result for example. items = [ VocabItem(u'1', u'A00.阿美族語(不分方言別)'), VocabItem(u'2', u'A01.北部阿美語'), VocabItem(u'3', u'A02.中部阿美語'), VocabItem(u'4', u'A03.海岸阿美語'), VocabItem(u'5', u'A04.馬蘭阿美語 '), VocabItem(u'6', u'A05.恆春阿美語'), VocabItem(u'7', u'B00.泰雅族語(不分方言別)'), VocabItem(u'8', u'B06.賽考利克泰雅語'), VocabItem(u'9', u'B07.澤敖利泰雅語'), VocabItem(u'10', u'B08.汶水泰雅語'), VocabItem(u'11', u'B09.萬大泰雅語'), VocabItem(u'12', u'B10.四季泰雅語'), VocabItem(u'13', u'B11.宜蘭澤敖利泰雅語'), VocabItem(u'14', u'C00.排灣族語(不分方言別)'), VocabItem(u'15', u'C12.東排灣語'), VocabItem(u'16', u'C13.北排灣語'), VocabItem(u'17', u'C14.中排灣語'), VocabItem(u'18', u'C15.南排灣語'), VocabItem(u'19', u'D00.布農族語(不分方言別)'), VocabItem(u'20', u'D16.卓群布農語'), VocabItem(u'21', u'D17.卡群布農語'), VocabItem(u'22', u'D18.丹群布農語'), VocabItem(u'23', u'D19.巒群布農語'), VocabItem(u'24', u'D20.郡群布農語'), VocabItem(u'25', u'E00.卑南族(不分方言別)'), VocabItem(u'26', u'E21.南王卑南語'), VocabItem(u'27', u'E22.知本卑南語'), VocabItem(u'28', u'E23.初鹿卑南語'), VocabItem(u'29', u'E24.建和卑南語'), VocabItem(u'30', u'F00.魯凱族語(不分方言別)'), VocabItem(u'31', u'F25.東魯凱語'), VocabItem(u'32', u'F26.霧台魯凱語'), VocabItem(u'33', u'G31.鄒語'), VocabItem(u'34', u'H32.卡那卡那富語'), VocabItem(u'35', u'J34.賽夏語'), VocabItem(u'36', u'K35.雅美語'), VocabItem(u'37', u'L36.邵語'), VocabItem(u'38', u'M37.噶瑪蘭語'), VocabItem(u'39', u'N38.太魯閣語'), VocabItem(u'40', u'P00.賽德克族語(不分方言別)'), VocabItem(u'41', u'P40.都達語'), VocabItem(u'42', u'P41.德固達雅語'), VocabItem(u'43', u'P42.德魯固語'), VocabItem(u'44', u'Q43.噶哈巫語'), ] # Fix context if you are using the vocabulary in DataGridField. # See https://github.com/collective/collective.z3cform.datagridfield/issues/31: # NOQA: 501 if not IDexterityContent.providedBy(context): req = getRequest() context = req.PARENTS[0] # create a list of SimpleTerm items: terms = [] for item in items: terms.append( SimpleTerm( value=item.token, token=str(item.token), title=item.value, )) # Create a SimpleVocabulary from the terms list and return it: return SimpleVocabulary(terms)
def createTerm(value, token, title, data): term = SimpleTerm(value, token, title) term.data = data return term
def get_vocabulary_type(): values = [u"Global", u"Local"] return SimpleVocabulary([ SimpleTerm(title=_(value), value=value, token=token) for token, value in enumerate(values) ])
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """ $Id$ """ from zope import component from zope.i18nmessageid import MessageFactory from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary from zope.lifecycleevent.interfaces import IObjectModifiedEvent _ = MessageFactory('zojax.company') tp1 = SimpleTerm('open', 'open', _('Open Company')) tp1.description = _('Non-members can view content and participate.') tp2 = SimpleTerm('members', 'members', _('Members Only Company')) tp2.description = _('Non-members can view content, but can not participate.') tp3 = SimpleTerm('private', 'private', _('Private Company')) tp3.description = _('Only members may participate, and the company ' 'is not listed in the group directory.') types = SimpleVocabulary((tp1, tp2, tp3))
def vocab_wiederaufnahme(context): return SimpleVocabulary(( SimpleTerm('nein', 'nein', u'nein'), SimpleTerm('ja, sofort', 'ja, sofort', u'ja, sofort'), SimpleTerm('ja, spaeter am:', 'ja, spaeter am:', u'ja, später am:'), ))
def createTerm(cls, brain, context): term = SimpleTerm(value=brain["UID"], token=brain["UID"], title=brain.Title) term.brain = brain return term
def vocab_prssex(context): return SimpleVocabulary((SimpleTerm('maennlich', 'maennlich', u'männlich'), SimpleTerm('weiblich', 'weiblich', u'weiblich')))