How to use the zope.schema 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 opennode / opennode-management / opennode / oms / model / model / search.py View on Github external
from .symlink import Symlink, follow_symlinks
from opennode.oms.model.model.events import IModelModifiedEvent, IModelCreatedEvent, IModelDeletedEvent


class ITokenized(Interface):
    def tokens():
        """Returns all tokens relevant for a model as a single string"""


class ITokenizer(Interface):
    def tokens():
        """Returns all tokens relevant for a model as a list of tokens"""


class ITagged(Interface):
    tags = schema.Set(title=u"Tags", required=False)


class ModelTokenizer(Adapter):
    implements(ITokenized)
    context(Model)

    def tokens(self):
        """Hackish way to quickly take all important tokens"""
        tokens = []
        if IDisplayName.providedBy(self.context):
            tokens.extend(IDisplayName(self.context).display_name().split('_'))

        if queryAdapter(self.context, ITagged):
            for tag in ITagged(self.context).tags:
                # hack, zope catalog treats ':' specially
                tokens.append(tag.replace(':', '_'))
github zopefoundation / z3c.form / src / z3c / form / browser / textarea.py View on Github external
@zope.component.adapter(zope.schema.interfaces.IField, interfaces.IFormLayer)
@zope.interface.implementer(interfaces.IFieldWidget)
def TextAreaFieldWidget(field, request):
    """IFieldWidget factory for TextWidget."""
    return FieldWidget(field, TextAreaWidget(request))
github collective / collective.nitf / src / collective / nitf / interfaces.py View on Github external
from zope import schema
from zope.interface import Interface


class INITFLayer(Interface):
    """ A layer specific for this add-on product."""


class INITF(model.Schema):
    """A News Article based on the News Industry Text Format specification."""

    # title = schema.TextLine()
    # nitf/head/title and nitf/body/body.head/hedline/hl1

    form.order_before(subtitle='IDublinCore.title')
    subtitle = schema.TextLine(
        # nitf/body/body.head/hedline/hl2
        title=_(u'Subtitle'),
        description=_(u'help_subtitle',
                      default=u'A subordinate headline for the article.'),
        default=u'',
        missing_value=u'',
        required=False,
    )

    byline = schema.TextLine(
        # nitf/body/body.head/byline/person
        title=_(u'Author'),
        default=u'',
        missing_value=u'',
        required=False,
    )
github ggozad / collective.classification / src / collective / classification / browser / suggestcategories.py View on Github external
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from zope.formlib import form
from plone.app.form.interfaces import IPlonePageForm
from Products.statusmessages.interfaces import IStatusMessage
from collective.classification.interfaces import IContentClassifier, \
    IClassifiable
from collective.classification import ClassificationMessageFactory as _
try:
    from five.formlib import formbase
except ImportError:
    from Products.Five.formlib import formbase

class ISuggestCategories(Interface):
    """
    """
    suggestions = schema.List(
        title = _(u"Suggestions"),
        description = _(u""),
        default = [])


class SuggestCategoriesView(formbase.PageForm):
    """Suggest categories to the user and let him set them.
    """

    implements(IPlonePageForm)
    label = _(u"Suggested categories")
    description = _(u"Choose among the proposed subjects. Clicking on apply "\
        "will add the chosen categories to the existing ones.")

    def getSuggestedSubjects(self):
        """
github collective / sc.social.like / sc / social / like / tiles / twitter.py View on Github external
u'Set the height of a displayed widget, overriding the value stored with the widget ID. '
            u'Must be greater than 200 pixels. '
            u'Note: this parameter does not apply if a tweet limit has been specified.'),
        required=False,
        default=500,
        min=200,
    )

    # form.widget('chrome', CheckBoxFieldWidget)
    # chrome = schema.Choice(
    #     title=_(u'Chrome'),
    #     required=False,
    #     vocabulary=ChromeOptions,
    # )

    tweet_limit = schema.Int(
        title=_(u'Tweet limit'),
        description=_(
            u'Display an expanded timeline of between 1 and 20 tweets. '
            u'Leave it empty to use the default or to set the height of the widget.'),
        required=False,
        default=None,
        min=1,
        max=20,
    )

    aria_polite = schema.Choice(
        title=_(u'WAI-ARIA politeness'),
        description=_(
            u'A timeline widget is a live region of a page which may receive updates as new tweets become available. '
            u'When specified as polite, assistive technologies will notify users of updates but generally do not interrupt the current task, and updates take low priority. '
            u'When specified as assertive, assistive technologies will immediately notify the user, and could potentially clear the speech queue of previous updates.'),
github plone / plone.app.event / plone / app / event / portlets / portlet_events.py View on Github external
class IEventsPortlet(IPortletDataProvider):

    count = schema.Int(
        title=_(u'Number of items to display'),
        description=_(u'How many items to list.'),
        required=True,
        default=5,
        min=1,
    )

    state = schema.Tuple(
        title=_(u"Workflow state"),
        description=_(u"Items in which workflow state to show."),
        default=None,
        required=False,
        value_type=schema.Choice(
            vocabulary="plone.app.vocabularies.WorkflowStates"
        )
    )

    search_base_uid = schema.Choice(
        title=_(u'portlet_label_search_base', default=u'Search base'),
        description=_(
            u'portlet_help_search_base',
            default=u'Select search base Folder or Collection to search for '
                    u'events. The URL to to this item will also be used to '
                    u'link to in calendar searches. If empty, the whole site '
                    u'will be searched and the event listing view will be '
                    u'called on the site root.'
        ),
        required=False,
        source=search_base_uid_source,
github plone / Products.CMFPlone / Products / CMFPlone / browser / interfaces.py View on Github external
required=True
    )

    comment = schema.Text(
        title=_(u'label_comment',
                default=u'Comment'),
        description=_(u'help_comment_to_link',
                      default=u'A comment about this link.'),
        required=False
    )


class IContactForm(Interface):
    """ Interface for describing the contact info form """

    sender_fullname = schema.TextLine(
        title=_(u'label_sender_fullname',
                default=u'Name'),
        description=_(u'help_sender_fullname',
                      default=u'Please enter your full name.'),
        required=True
    )

    sender_from_address = Email(
        title=_(u'label_sender_from_address',
                default=u'From'),
        description=_(u'help_sender_from_address',
                      default=u'Please enter your e-mail address.'),
        required=True
    )

    subject = schema.TextLine(
github collective / collective.collectionfilter / src / collective / collectionfilter / interfaces.py View on Github external
default_map_layer = schema.Choice(
            title=_(
                u'default_map_layer',
                u'Default map layer'
            ),
            description=_(
                u'help_default_map_layer',
                default=u'Set the default map layer'
            ),
            required=False,
            defaultFactory=map_layer_default,
            vocabulary='plone.formwidget.geolocation.vocabularies.map_layers'
        )

        map_layers = schema.List(
            title=_(u'label_map_layers', u'Map Layers'),
            description=_(
                u'help_map_layers',
                default=u'Set the available map layers'),
            required=False,
            defaultFactory=map_layers_default,
            missing_value=[],
            value_type=schema.Choice(vocabulary='plone.formwidget.geolocation.vocabularies.map_layers'))  # noqa: E501
github plone / plone.restapi / src / plone / restapi / serializer / controlpanels.py View on Github external
def __call__(self):
        json_schema = get_jsonschema_for_controlpanel(
            self.controlpanel, self.controlpanel.context, self.controlpanel.request
        )

        proxy = self.registry.forInterface(self.schema, prefix=self.schema_prefix)

        # Temporarily provide IDexterityContent, so we can use DX field
        # serializers
        alsoProvides(proxy, IDexterityContent)

        json_data = {}
        for name, field in zope.schema.getFields(self.schema).items():
            serializer = queryMultiAdapter(
                (field, proxy, self.controlpanel.request), IFieldSerializer
            )
            if serializer:
                value = serializer()
            else:
                value = getattr(proxy, name, None)
            json_data[json_compatible(name)] = value

        noLongerProvides(proxy, IDexterityContent)

        # JSON schema
        return {
            "@id": "{}/{}/{}".format(
                self.controlpanel.context.absolute_url(),
                SERVICE_ID,
github plone / plone.app.tiles / plone / app / tiles / demo.py View on Github external
class ITransientTileData(Interface):

    message = schema.TextLine(title=u"Test string")


class TransientTile(tiles.Tile):

    def __call__(self):
        return "<b>Transient tile %s</b>" % \
            self.data['message']


class IPersistentTileData(Interface):

    message = schema.TextLine(title=u"Persisted message")
    counter = schema.Int(title=u"Counter")

    fieldset(
        'counter',
        label=u"Counter",
        fields=['counter'])


class PersistentTile(tiles.PersistentTile):

    def __call__(self):
        return "<b>Persistent tile %s #%d</b>" % \
            (self.data['message'], self.data['counter'],)