How to use the zope.schema.Choice function in Zope

To help you get started, we’ve selected a few Zope examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plone / plone.app.dexterity / plone / app / dexterity / behaviors / metadata.py View on Github external
description=_(
            u'help_tags',
            default=u'Tags are commonly used for ad-hoc organization of ' +
                    u'content.'
        ),
        value_type=schema.TextLine(),
        required=False,
        missing_value=(),
    )
    directives.widget(
        'subjects',
        AjaxSelectFieldWidget,
        vocabulary='plone.app.vocabularies.Keywords'
    )

    language = schema.Choice(
        title=_(u'label_language', default=u'Language'),
        vocabulary='plone.app.vocabularies.SupportedContentLanguages',
        required=False,
        missing_value='',
        defaultFactory=default_language,
    )
    directives.widget('language', SelectFieldWidget)

    directives.omitted('subjects', 'language')
    directives.no_omit(IEditForm, 'subjects', 'language')
    directives.no_omit(IAddForm, 'subjects', 'language')


class EffectiveAfterExpires(Invalid):
    __doc__ = _('error_invalid_publication',
                default=u'Invalid effective or expires date')
github plone / plone.app.dexterity / plone / app / dexterity / behaviors / discussion.py View on Github external
options = SimpleVocabulary([
    SimpleTerm(value=True, title=_(u'Yes')),
    SimpleTerm(value=False, title=_(u'No')),
])


@provider(IFormFieldProvider)
class IAllowDiscussion(model.Schema):

    model.fieldset(
        'settings',
        label=_(u"Settings"),
        fields=['allow_discussion'],
    )

    allow_discussion = schema.Choice(
        title=_(u'Allow discussion'),
        description=_(u'Allow discussion for this content object.'),
        vocabulary=options,
        required=False,
        default=None,
    )

    directives.omitted('allow_discussion')
    directives.no_omit(IEditForm, 'allow_discussion')
    directives.no_omit(IAddForm, 'allow_discussion')
github plone / plone.app.deco / plone / app / deco / browser / manage.py View on Github external
description = schema.Text(
            title=_(u"Description"),
            description=_(u"A short description for the page type"),
            required=False,
        )
    
    defaultSiteLayout = schema.Choice(
            title=_(u"Default site layout"),
            description=_(u"The default site layout used when creating new pages of this type" +
                          u"If no value is selected, the parent or global default will be used."),
            vocabulary='plone.availableSiteLayouts',
            required=False,
        )
    
    defaultPageLayoutTemplate = schema.Choice(
            title=_(u"Default page layout template"),
            description=_(u"The default page layout template used when creating new pages of this type"),
            vocabulary='plone.availablePageLayouts',
        )

class AddPageTypeForm(form.Form):
    
    fields = field.Fields(IPageTypeForm)
    ignoreContext = True
    
    defaultType = DEFAULT_PAGE_TYPE_NAME
    
    label = _(u"Add page type")
    
    @button.buttonAndHandler(_(u"Save"))
    def handleSave(self, action):
github innocenceproject / collective.salesforce.fundraising / collective / salesforce / fundraising / controlpanel / interfaces.py View on Github external
default_email_personal_page_donation = schema.Choice(
        title=_(u"Email Template - Personal Page Donation Email"),
        description=_(u"Provide the path to the chimpdrill template to use by default for personal page donation emails."),
        required=False,
        vocabulary=u'collective.salesforce.fundraising.personal_page_donation_templates',
    )

    email_recurring_receipt = schema.Choice(
        title=_(u"Email Template - Recurring Donation Receipt"),
        description=_(u"For recurring donations, the email template used to send receipts on recurring charges.  The first charge is sent the normal thank you email."),
        required=False,
        vocabulary=u'collective.salesforce.fundraising.recurring_receipt_templates',
    )

    email_recurring_failed_first = schema.Choice(
        title=_(u"Email Template - Recurring Payment Failed, First Time"),
        description=_(u"For recurring donations, the email template used to notify a donor that their recurring payment failed to process for the first time."),
        required=False,
        vocabulary=u'collective.salesforce.fundraising.recurring_receipt_templates',
    )

    email_recurring_failed_second = schema.Choice(
        title=_(u"Email Template - Recurring Payment Failed, Second Time"),
        description=_(u"For recurring donations, the email template used to notify a donor that their recurring payment failed to process for the second time."),
        required=False,
        vocabulary=u'collective.salesforce.fundraising.recurring_receipt_templates',
    )

    email_recurring_failed_third = schema.Choice(
        title=_(u"Email Template - Recurring Payment Failed, Third Time"),
        description=_(u"For recurring donations, the email template used to notify a donor that their recurring payment failed to process for the third time."),
github andymckay / arecibo / clients / plone / clearwind.arecibo / clearwind / arecibo / interfaces.py View on Github external
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('clearwind.arecibo')

arecibo_choices = {
    _(u"Send via http"): "http",
    _(u"Send via email"): "smtp"
}
arecibo_choices_vocab = SimpleVocabulary(
    [SimpleTerm(v, v, k) for k, v in arecibo_choices.items()]
    )

class IAreciboConfiguration(Interface):
  """ This interface defines the configlet."""
  account_number = TextLine(title=_(u"Arecibo public account number"),
                                  required=True)
  transport = Choice(title=_(u'Transport'),
                description=_(u"""How errors will be sent to Arecibo, for mail
                to work, your mail host must be correctly configured."""),
                default='http',
                vocabulary=arecibo_choices_vocab,
                required=False)
github castlecms / castle.cms / castle / cms / blocks / layoutbehavior.py View on Github external
"""

    content = LayoutField(
        title=_(u"Custom layout"),
        description=_(u"Custom content and content layout of this page"),
        default=None,
        required=False
    )

    contentLayout = schema.ASCIILine(
        title=_(u'Content Layout'),
        description=_(u'Selected content layout. If selected, custom layout is ignored.'),
        required=False)

    form.mode(pageSiteLayout='hidden')
    pageSiteLayout = schema.Choice(
        title=_(u"Site layout"),
        description=_(u"Site layout to apply to this page "
                      u"instead of the default site layout"),
        vocabulary="plone.availableSiteLayouts",
        required=False
    )
    write_permission(pageSiteLayout="plone.ManageSiteLayouts")

    form.mode(sectionSiteLayout='hidden')
    sectionSiteLayout = schema.Choice(
        title=_(u"Section site layout"),
        description=_(u"Site layout to apply to sub-pages of this page "
                      u"instead of the default site layout"),
        vocabulary="plone.availableSiteLayouts",
        required=False
    )
github plone / plone.schemaeditor / plone / schemaeditor / fields.py View on Github external
validator.WidgetValidatorDiscriminators(
    VocabularyNameValidator,
    field=se_schema.ITextLineChoice['vocabularyName'])


@interface.implementer(interfaces.IFieldEditFormSchema)
@component.adapter(schema_ifaces.ISet)
def getMultiChoiceFieldSchema(field):
    return se_schema.ITextLineChoice


MultiChoiceFactory = FieldFactory(
    schema.Set,
    _(u'label_multi_choice_field', default=u'Multiple Choice'),
    value_type=schema.Choice(values=[]))


@interface.implementer_only(se_schema.ITextLineChoice)
@component.adapter(schema_ifaces.ISet)
class TextLineMultiChoiceField(TextLineChoiceField):

    def __init__(self, field):
        self.__dict__['field'] = field

    def __getattr__(self, name):
        field = self.field
        if name == 'values':
            values = []
            for term in (self.field.value_type.vocabulary or []):
                if term.value != term.title:
                    values.append(u'{0:s}|{1:s}'.format(
github plone / plone.app.multilingual / src / plone / app / multilingual / interfaces.py View on Github external
default=7,
        required=False,
    )

    google_translation_key = schema.TextLine(
        title=_(
            u"heading_google_translation_key",
            default=u"Google Translation API Key"),
        description=_(
            u"description_google_translation_key",
            default=u"Is a paying API in order to use google translation "
                    u"service"),
        required=False,
    )

    selector_lookup_translations_policy = schema.Choice(
        title=_(u"heading_selector_lookup_translations_policy",
                default=u"The policy used to determine how the lookup for "
                        u"available translations will be made by the language "
                        u"selector."),
        description=_(u"description_selector_lookup_translations_policy",
                      default=u"The default language used for the content "
                              u"and the UI of this site."),
        required=True,
        vocabulary=selector_policies
    )
github plone / Products.CMFPlone / Products / CMFPlone / interfaces / controlpanel.py View on Github external
)

    available_expr = schema.ASCIILine(
        title=_(u'action_condition_heading', default=u'Condition'),
        description=_(
            u'action_condition_description',
            default=u'A boolean expression'
        ),
        required=False)

    permissions = schema.List(
        title=_(u'action_permissions_heading', default=u'Permissions'),
        required=True,
        default=['View'],
        missing_value=[],
        value_type=schema.Choice(
            vocabulary='plone.app.vocabularies.Permissions'
        )
    )

    visible = schema.Bool(
        title=_(u'action_visibility_heading', default=u'Visible?'),
        default=True,
        required=False)

    position = schema.Int(
        title=_(u'action_position_heading', default=u'Position'),
        default=1,
        min=1,
        required=True)
github castlecms / castle.cms / castle / cms / tiles / navigation.py View on Github external
name = 'horizontal'
    order = 0
    index = ViewPageTemplateFile('templates/navigation/horizontal.pt')
    tile_name = 'navigation'


class VerticalView(BaseTileView):
    name = 'vertical'
    order = 10
    index = ViewPageTemplateFile('templates/navigation/vertical.pt')
    tile_name = 'navigation'


class INavigationTileSchema(model.Schema):

    display_type = schema.Choice(
        title=u"Display Type",
        source=TileViewsSource('navigation'),
        default='horizontal'
    )

    form.widget(content=RelatedItemsFieldWidget)
    content = schema.List(
        title=u"Navigation items",
        description=u"Select items for navigation",
        required=False,
        default=[],
        value_type=schema.Choice(
            vocabulary='plone.app.vocabularies.Catalog'
        )
    )