Beispiel #1
0
class IPloneCacheSettings(Interface):
    """Settings stored in the registry.

    Basic cache settings are represented by
    ``plone.caching.interfaces.ICacheSettings``. These are additional,
    Plone-specific settings.
    """

    enableCompression = schema.Bool(
        title=_(u"Enable GZip compression"),
        description=_(u"Determine whether GZip compression should be "
                      u"enabled for standard responses"),
        default=False,
        required=True,
    )

    templateRulesetMapping = schema.Dict(
        title=_(u"Page template/ruleset mapping"),
        description=_(u"Maps skin layer page template names to ruleset names"),
        key_type=schema.ASCIILine(title=_(u"Page template name")),
        value_type=schema.DottedName(title=_(u"Ruleset name")),
    )

    contentTypeRulesetMapping = schema.Dict(
        title=_(u"Content type/ruleset mapping"),
        description=_(u"Maps content type names to ruleset names"),
        key_type=schema.ASCIILine(title=_(u"Content type name")),
        value_type=schema.DottedName(title=_(u"Ruleset name")),
    )

    purgedContentTypes = schema.Tuple(
        title=_(u"Content types to purge"),
        description=_(
            u"List content types which should be purged when modified"),
        value_type=schema.ASCIILine(title=_(u"Content type name")),
        default=(
            'File',
            'Image',
            'News Item',
        ),
    )

    cacheStopRequestVariables = schema.Tuple(
        title=_(u"Request variables that prevent caching"),
        description=_(
            u"Variables in the request that prevent caching if present"),
        value_type=schema.ASCIILine(title=_(u"Request variables")),
        default=(
            'statusmessages',
            'SearchableText',
        ),
    )
Beispiel #2
0
class ITileDirective(Interface):
    """Directive which registers a new type of tile
    """

    name = schema.DottedName(
        title=u"Name",
        description=u"A unique, dotted name for the tile",
    )

    title = MessageID(
        title=u"Title",
        description=u"A user friendly title, used when configuring the tile",
        required=False)

    description = MessageID(
        title=u"Description",
        description=u"A longer summary of the tile's purpose and function",
        required=False)

    icon = MessageID(
        title=u"Icon",
        description=u"Image that represents tile purpose and function",
        required=False)

    add_permission = Permission(
        title=u"Add permission",
        description=u"Name of the permission required to instantiate "
        u"this tile",
        required=False,
    )

    schema = GlobalInterface(
        title=u"Configuration schema for the tile",
        description=u"This is used to create standard add/edit forms",
        required=False,
    )

    for_ = GlobalObject(
        title=u"The interface or class this tile is available for",
        required=False,
    )

    layer = GlobalInterface(title=u"The layer the tile is available for",
                            required=False)

    class_ = GlobalObject(title=u"Class",
                          description=u"Class implementing this tile",
                          required=False)

    template = Path(
        title=u"The name of a template that renders this tile",
        description=u"Refers to a file containing a page template",
        required=False,
    )

    permission = Permission(
        title=u"View permission",
        description=u"Name of the permission required to view this item",
        required=False,
    )
Beispiel #3
0
class ICacheSettings(Interface):
    """Settings expected to be found in plone.registry
    """

    enabled = schema.Bool(
        title=_(u'Globally enabled'),
        description=_(u'If not set, no caching operations will be attempted'),
        default=False,
    )

    operationMapping = schema.Dict(
        title=_(u'Rule set/operation mapping'),
        description=_(u'Maps rule set names to operation names'),
        key_type=schema.DottedName(title=_(u'Rule set name')),
        value_type=schema.DottedName(title=_(u'Caching operation name')),
    )
Beispiel #4
0
class IRulesetType(Interface):
    """A ruleset type. The name can be used in a <cache:ruleset /> directive.
    The title and description are used for UI support.
    """
    
    name        = schema.DottedName(title=u"Ruleset name")
    title       = schema.TextLine(title=u"Title")
    description = schema.TextLine(title=u"Description", required=False)
Beispiel #5
0
class IPloneCacheSettings(Interface):
    """Settings stored in the registry.

    Basic cache settings are represented by
    ``plone.caching.interfaces.ICacheSettings``. These are additional,
    Plone-specific settings.
    """

    templateRulesetMapping = schema.Dict(
        title=_(u'Page template/ruleset mapping'),
        description=_(u'Maps skin layer page template names to ruleset names'),
        key_type=schema.ASCIILine(title=_(u'Page template name')),
        value_type=schema.DottedName(title=_(u'Ruleset name')),
    )

    contentTypeRulesetMapping = schema.Dict(
        title=_(u'Content type/ruleset mapping'),
        description=_(u'Maps content type names to ruleset names'),
        key_type=schema.ASCIILine(title=_(u'Content type name')),
        value_type=schema.DottedName(title=_(u'Ruleset name')),
    )

    purgedContentTypes = schema.Tuple(
        title=_(u'Content types to purge'),
        description=_(
            u'List content types which should be purged when modified'),
        value_type=schema.ASCIILine(title=_(u'Content type name')),
        default=(
            'File',
            'Image',
            'News Item',
        ),
    )

    cacheStopRequestVariables = schema.Tuple(
        title=_(u'Request variables that prevent caching'),
        description=_(
            u'Variables in the request that prevent caching if present'),
        value_type=schema.ASCIILine(title=_(u'Request variables')),
        default=(
            'statusmessages',
            'SearchableText',
        ),
    )
Beispiel #6
0
class IFieldRef(Interface):
    """A reference to another field.

    This allows a record to use a field that belongs to another record. Field
    refs are allowed in the Record() constructor.

    Note that all attributes are read-only.
    """

    recordName = schema.DottedName(
        title=u"Name of the record containing the reference field")
    originalField = schema.Object(title=u"Referenced field", schema=IField)
Beispiel #7
0
class IRegistry(Interface):
    """The configuration registry
    """

    records = schema.Dict(
        title=u'The records of the registry',
        key_type=schema.DottedName(
            title=u'Name of the record',
            description=u'By convention, this should include the '
            u'package name and optionally an interface '
            u'named, if the record can be described by a '
            u'field in an interface (see also '
            u'registerInterface() below), e.g. '
            u'my.package.interfaces.IMySettings.somefield.',
        ),
        value_type=schema.Object(
            title=u'The record for this name',
            schema=IRecord,
        ),
    )

    def __getitem__(key):
        """Get the value under the given key. A record must have been
        installed for this key for this to be valid. Otherwise, a KeyError is
        raised.
        """

    def get(key, default=None):
        """Attempt to get the value under the given key. If it does not
        exist, return the given default.
        """

    def __setitem__(key, value):
        """Set the value under the given key. A record must have been
        installed for this key for this to be valid. Otherwise, a KeyError is
        raised. If value is not of a type that's allowed by the record, a
        ValidationError is raised.
        """

    def __contains__(key):
        """Determine if the registry contains a record for the given key.
        """

    def forInterface(interface, check=True, omit=(), prefix=None):
        """Get an IRecordsProxy for the given interface. If `check` is True,
        an error will be raised if one or more fields in the interface does
        not have an equivalent setting.
        """

    def registerInterface(interface, omit=(), prefix=None):
        """Create a set of records based on the given interface. For each
Beispiel #8
0
class IInterfaceAwareRecord(Interface):
    """A record will be marked with this interface if it knows which
    interface its field came from.
    """

    interfaceName = schema.DottedName(title=u"Dotted name to interface")

    interface = schema.Object(
        title=u"Interface that provided the record",
        description=u"May be None if the interface is no longer available",
        schema=IInterface,
        readonly=True)

    fieldName = schema.ASCIILine(
        title=u"Name of the field in the original interface")
Beispiel #9
0
class IListUsersSettings(Interface):
    """Global settings for the package"""

    # TODO: use FrozenSet once we fix
    # https://github.com/collective/collective.elephantvocabulary/issues/1
    exclude_groups = schema.List(
        title=_(u'What groups to exclude from the product'),
        description=
        _(u'Select groups that should not show up in widgets or user list table'
          ),
        value_type=schema.Choice(vocabulary='plone.app.vocabularies.Groups', ),
        defaultFactory=default_settings_exclude_groups,
    )
    filter_by_member_properties_attribute = schema.Choice(
        title=_(u'User property'),
        description=_(
            u'What member property to filter on based on defined vocabulary'),
        vocabulary='collective.listusers.vocabularies.UserAttributes',
    )
    filter_by_member_properties_vocabulary = schema.DottedName(
        title=_(u'Dotted name to Vocabulary'),
        description=_(
            u'Select vocabulary used for filtering by member attribute'),
        constraint=validate_vocabulary,
        required=False,
    )
    enable_user_attributes_widget = schema.Bool(
        title=_(u"label_enable_user_attributes_widget",
                default=u"Enable user attributes widget"),
        description=_(
            u"help_enable_user_attributes_widget",
            default=
            u"If checked, it will display widget to select user attributes to show in table"
        ),
        required=False,
        default=True,
    )
    default_user_attributes = schema.List(
        title=_(u'Default user attributes'),
        description=_(u'Select which user attributes you want displayed in ' \
            'the results table.'),
        value_type=schema.Choice(
            vocabulary='collective.listusers.vocabularies.UserAttributes',
        ),
        constraint=must_select_one_constraint,
        defaultFactory=default_settings_user_attributes,
    )
Beispiel #10
0
class IPersistentField(IField):
    """A field that can be persistent along with a record.

    We provide our own implementation of the basic field types that are
    supported by the registry.

    A persistent field may track which interface and field it originally
    was constructed from. This is done by the registerInterface() method
    on the IRegistry, for example. Only the interface/field names are stored,
    not actual object references.
    """

    interfaceName = schema.DottedName(
        title=u"Dotted name to an interface the field was constructed from",
        required=False)
    fieldName = schema.ASCIILine(
        title=u"Name of the field in the original interface, if any",
        required=False)
Beispiel #11
0
class ICachingOperationType(Interface):
    """A named utility which is used to provide UI support for caching
    operations. The name should correspond to the operation adapter name.

    The usual pattern is::

        from plone.caching.interfaces import ICachingOperation
        from plone.caching.interfaces import ICachingOperationType
        from plone.caching.utils import lookupOptions
        from zope.component import adapter
        from zope.interface import implementer
        from zope.interface import Interface
        from zope.interface import provider


        @implementer(ICachingOperation)
        @adapter(Interface, Interface)
        @provider(ICachingOperationType)
        class SomeOperation(object):

            title = u"Some operation"
            description = u"Operation description"
            prefix = 'my.package.operation1'
            options = ('option1', 'option2')

            def __init__(self, published, request):
                self.published = published
                self.request = request

            def __call__(self, rulename, response):
                options = lookupOptions(SomeOperation, rulename)
                ...

    This defines an adapter factory (the class), which itself provides
    information about the type of operation. In ZCML, these would be
    registered with::

        <adapter factory=".ops.SomeOperation" name="my.package.operation1" />
        <utility component=".ops.SomeOperation" name="my.package.operation1" />

    Note that the use of *component* for the ``<utility />`` registration - we
    are registering the class as a utility. Also note that the utility and
    adapter names must match. By convention, the option prefix should be the
    same as the adapter/utility name.

    You could also register an instance as a utility, of course.
    """

    title = schema.TextLine(
        title=_(u'Title'),
        description=_(u'A descriptive title for the operation'),
    )

    description = schema.Text(
        title=_(u'Description'),
        description=_(u'A longer description for the operaton'),
        required=False,
    )

    prefix = schema.DottedName(
        title=_(u'Registry prefix'),
        description=_(u'Prefix for records in the registry pertaining to '
                      u'this operation. This, alongside the next '
                      u'parameter, allows the user interface to present '
                      u'relevant configuration options for this '
                      u'operation.'),
        required=False,
    )

    options = schema.Tuple(
        title=_(u'Registry options'),
        description=_(u'A tuple of options which can be used to '
                      u'configure this operation. An option is looked '
                      u'up in the registry by concatenating the prefix '
                      u'with the option name, optionally preceded by '
                      u'the rule set name, to allow per-rule overrides.'),
        value_type=schema.DottedName(),
        required=False,
    )
Beispiel #12
0
class IExample(model.Schema):
    """Dexterity-Schema with all field-types."""

    # The most used fields
    # textline, text, bool, richtext, email

    fieldset(
        "numberfields",
        label=u"Number fields",
        fields=("int_field", "float_field"),
    )

    fieldset(
        "datetimefields",
        label=u"Date and time fields",
        fields=(
            "datetime_field",
            "date_field",
            "time_field",
            "timedelta_field",
        ),
    )

    fieldset(
        "choicefields",
        label=u"Choice and Multiple Choice fields",
        fields=(
            "choice_field",
            "choice_field_radio",
            "choice_field_select",
            "choice_field_voc",
            "list_field",
            "list_field_checkbox",
            "list_field_select",
            "list_field_voc_unconstrained",
            "tuple_field",
            "set_field",
            "set_field_checkbox",
        ),
    )

    fieldset(
        "relationfields",
        label=u"Relation fields",
        fields=(
            "relationchoice_field",
            "relationlist_field",
            "relationchoice_field_constrained",
            "relationlist_field_constrained",
            "relationlist_field_search_mode",
            "relationchoice_field_select",
            "relationchoice_field_radio",
            "relationlist_field_select",
            "relationlist_field_checkbox",
            "relationchoice_field_ajax_select",
            "relationlist_field_ajax_select",
        ),
    )

    fieldset(
        "uuidrelationfields",
        label=u"Relation widgets with uuids",
        fields=(
            "uuid_choice_field",
            "uuid_list_field",
            "uuid_choice_field_constrained",
            "uuid_list_field_constrained",
            "uuid_list_field_search_mode",
            "uuid_choice_field_select",
            "uuid_choice_field_radio",
            "uuid_list_field_select",
            "uuid_list_field_checkbox",
            "uuid_choice_field_ajax_select",
            "uuid_list_field_ajax_select",
        ),
    )

    fieldset(
        "filefields",
        label=u"File fields",
        fields=("file_field", "image_field"),
    )

    fieldset(
        "otherfields",
        label=u"Other fields",
        fields=(
            "uri_field",
            "sourcetext_field",
            "ascii_field",
            "bytesline_field",
            "asciiline_field",
            "pythonidentifier_field",
            "dottedname_field",
            # 'dict_field',
            # "vocabularyterms_field",
            # "vocabularytermstranslation_field",
            # 'dict_field_with_choice',
        ),
    )

    fieldset(
        "datagrid",
        label=u"Datagrid field",
        fields=("datagrid_field", ),
    )

    primary("title")
    title = schema.TextLine(
        title=u"Primary Field (Textline)",
        description=u"zope.schema.TextLine",
        required=True,
    )

    description = schema.TextLine(
        title=u"Description (Textline)",
        description=u"zope.schema.TextLine",
        required=False,
    )

    text_field = schema.Text(
        title=u"Text Field",
        description=u"zope.schema.Text",
        required=False,
        missing_value=u"",
    )

    textline_field = schema.TextLine(
        title=u"Textline field",
        description=u"A simple input field (schema.TextLine)",
        required=False,
    )

    bool_field = schema.Bool(
        title=u"Boolean field",
        description=u"zope.schema.Bool",
        required=False,
    )

    choice_field = schema.Choice(
        title=u"Choice field",
        description=u"zope.schema.Choice",
        values=[u"One", u"Two", u"Three"],
        required=True,
    )

    directives.widget(choice_field_radio=RadioFieldWidget)
    choice_field_radio = schema.Choice(
        title=u"Choice field with radio boxes",
        description=u"zope.schema.Choice",
        values=[u"One", u"Two", u"Three"],
        required=False,
    )

    choice_field_voc = schema.Choice(
        title=u"Choicefield with values from named vocabulary",
        description=u"zope.schema.Choice",
        vocabulary="plone.app.vocabularies.PortalTypes",
        required=False,
    )

    directives.widget(choice_field_select=SelectFieldWidget)
    choice_field_select = schema.Choice(
        title=u"Choicefield with select2 widget",
        description=u"zope.schema.Choice",
        vocabulary="plone.app.vocabularies.PortalTypes",
        required=False,
    )

    list_field = schema.List(
        title=u"List field",
        description=u"zope.schema.List",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=[],
    )

    directives.widget(list_field_checkbox=CheckBoxFieldWidget)
    list_field_checkbox = schema.List(
        title=u"List field with checkboxes",
        description=u"zope.schema.List",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=[],
    )

    directives.widget(list_field_select=SelectFieldWidget)
    list_field_select = schema.List(
        title=u"List field with select widget",
        description=u"zope.schema.List",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=[],
    )

    list_field_voc_unconstrained = schema.List(
        title=
        u"List field with values from vocabulary but not constrained to them.",
        description=u"zope.schema.List",
        value_type=schema.TextLine(),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "list_field_voc_unconstrained",
        AjaxSelectFieldWidget,
        vocabulary="plone.app.vocabularies.PortalTypes",
        pattern_options={
            "closeOnSelect":
            False,  # Select2 option to leave dropdown open for multiple selection
        },
    )

    tuple_field = schema.Tuple(
        title=u"Tuple field",
        description=u"zope.schema.Tuple",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value=(),
    )

    set_field = schema.Set(
        title=u"Set field",
        description=u"zope.schema.Set",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value={},
    )

    directives.widget(set_field_checkbox=CheckBoxFieldWidget)
    set_field_checkbox = schema.Set(
        title=u"Set field with checkboxes",
        description=u"zope.schema.Set",
        value_type=schema.Choice(
            values=[u"Beginner", u"Advanced", u"Professional"], ),
        required=False,
        missing_value={},
    )

    # File fields
    image_field = NamedBlobImage(
        title=u"Image field",
        description=
        u"A upload field for images (plone.namedfile.field.NamedBlobImage)",
        required=False,
    )

    file_field = NamedBlobFile(
        title=u"File field",
        description=
        u"A upload field for files (plone.namedfile.field.NamedBlobFile)",
        required=False,
    )

    # Date and Time fields
    datetime_field = schema.Datetime(
        title=u"Datetime field",
        description=u"Uses a date and time picker (zope.schema.Datetime)",
        required=False,
    )

    date_field = schema.Date(
        title=u"Date field",
        description=u"Uses a date picker (zope.schema.Date)",
        required=False,
    )

    time_field = schema.Time(
        title=u"Time field",
        description=u"zope.schema.Time",
        required=False,
    )

    timedelta_field = schema.Timedelta(
        title=u"Timedelta field",
        description=u"zope.schema.Timedelta",
        required=False,
    )

    # Relation Fields
    relationchoice_field = RelationChoice(
        title=u"Relationchoice field",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )

    relationlist_field = RelationList(
        title=u"Relationlist Field",
        description=u"z3c.relationfield.schema.RelationList",
        default=[],
        value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )

    relationchoice_field_constrained = RelationChoice(
        title=u"Relationchoice field (only allows Documents)",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )
    directives.widget(
        "relationchoice_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document"]},
    )

    relationlist_field_constrained = RelationList(
        title=u"Relationlist Field (only allows Documents and Events)",
        description=u"z3c.relationfield.schema.RelationList",
        default=[],
        value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "relationlist_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document", "Event"]},
    )

    relationlist_field_search_mode = RelationList(
        title=
        u"Relationlist Field in Search Mode (constrained to published Documents and Events)",
        description=u"z3c.relationfield.schema.RelationList",
        default=[],
        value_type=RelationChoice(source=CatalogSource(
            portal_type=["Document", "Event"], review_state="published")),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "relationlist_field_search_mode",
        RelatedItemsFieldWidget,
        pattern_options={
            "baseCriteria":
            [  # This is a optimization that limits the catalog-query
                {
                    "i": "portal_type",
                    "o": "plone.app.querystring.operation.selection.any",
                    "v": ["Document", "Event"],
                },
                {
                    "i": "review_state",
                    "o": "plone.app.querystring.operation.selection.any",
                    "v": "published",
                },
            ],
            "mode":
            "search",
        },
    )

    # From here on we use other widgets than the default RelatedItemsFieldWidget

    # This one also works in Volto!
    # All other options use the default ObjectWidget in Volto so far.
    relationchoice_field_select = RelationChoice(
        title=u"RelationChoice with Select Widget",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state": "published",
        }),
        required=False,
    )
    directives.widget(
        "relationchoice_field_select",
        SelectFieldWidget,
    )

    relationchoice_field_radio = RelationChoice(
        title=
        u"RelationChoice with Radio Widget (and customized title-template)",
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event"],
                "review_state": "published",
            },
            title_template="{brain.Title}",
        ),  # Set a custom vocabulary item title
        required=False,
    )
    directives.widget(
        "relationchoice_field_radio",
        RadioFieldWidget,
    )

    relationlist_field_select = RelationList(
        title=
        u"RelationList with select widget with items from a named vocabulary",
        value_type=RelationChoice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "relationlist_field_select",
        SelectFieldWidget,
        pattern_options={
            "closeOnSelect":
            False,  # Select2 option to leave dropdown open for multiple selection
        },
    )

    relationlist_field_checkbox = RelationList(
        title=u"RelationList with Checkboxes",
        value_type=RelationChoice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "relationlist_field_checkbox",
        CheckBoxFieldWidget,
    )

    relationchoice_field_ajax_select = RelationChoice(
        title=u"Relationchoice Field with AJAXSelect",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        required=False,
    )
    directives.widget(
        "relationchoice_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
        },
    )

    relationlist_field_ajax_select = RelationList(
        title=u"Relationlist Field with AJAXSelect",
        description=u"z3c.relationfield.schema.RelationList",
        value_type=RelationChoice(vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state":
            "published",
        })),
        required=False,
    )
    directives.widget(
        "relationlist_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event", "Folder"],
            },
            title_template="{brain.Type}: {brain.Title} at {path}",
        ),  # Custom item rendering
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
        },
    )

    # These look like relationsfields (see above) but only store the uuid(s) of the selected target
    # as a string in a the field instead of a RelationValue.
    # A good way to use these is in combination with a index that allows you to query these connenctions.
    uuid_choice_field = schema.Choice(
        title=u"Choice field with RelatedItems widget storing uuids",
        description=u"schema.Choice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )
    directives.widget("uuid_choice_field", RelatedItemsFieldWidget)

    uuid_list_field = schema.List(
        title=u"List Field with RelatedItems widget storing uuids",
        description=u"schema.List",
        default=[],
        value_type=schema.Choice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )
    directives.widget("uuid_list_field", RelatedItemsFieldWidget)

    uuid_choice_field_constrained = schema.Choice(
        title=
        u"Choice field with RelatedItems widget storing uuids (only allows Documents)",
        description=u"schema.Choice",
        vocabulary="plone.app.vocabularies.Catalog",
        required=False,
    )
    directives.widget(
        "uuid_choice_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document"]},
    )

    uuid_list_field_constrained = schema.List(
        title=
        u"List Field with RelatedItems widget storing uuids (only allows Documents and Events)",
        description=u"schema.List",
        default=[],
        value_type=schema.Choice(vocabulary="plone.app.vocabularies.Catalog"),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "uuid_list_field_constrained",
        RelatedItemsFieldWidget,
        pattern_options={"selectableTypes": ["Document", "Folder"]},
    )

    uuid_list_field_search_mode = schema.List(
        title=
        u"List Field with RelatedItems widget in Search Mode storing uuids",
        description=u"schema.List",
        default=[],
        value_type=schema.Choice(source=CatalogSource(
            portal_type=["Document", "Event"], review_state="published")),
        required=False,
        missing_value=[],
    )
    directives.widget(
        "uuid_list_field_search_mode",
        RelatedItemsFieldWidget,
        pattern_options={
            "selectableTypes": ["Document", "Folder"],
            "basePath": "",  # Start the search at the portal root
            "mode": "search",
        },
    )

    # From here on we use other widgets than the default RelatedItemsFieldWidget

    uuid_choice_field_select = schema.Choice(
        title=u"UUID Choice with select widget storing uuids",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state": "published",
        }),
        required=False,
    )
    directives.widget(
        "uuid_choice_field_select",
        SelectFieldWidget,
    )

    uuid_choice_field_radio = schema.Choice(
        title=u"RelationChoice with Radio widget storing uuids",
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event"],
                "review_state": "published",
            },
            title_template="{brain.Title}",
        ),  # Set a custom vocabulary item title
        required=False,
    )
    directives.widget(
        "uuid_choice_field_radio",
        RadioFieldWidget,
    )

    uuid_list_field_select = schema.List(
        title=
        u"RelationList with select widget with items from a named vocabulary storing uuids",
        value_type=schema.Choice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "uuid_list_field_select",
        SelectFieldWidget,
        pattern_options={
            "closeOnSelect":
            False,  # Select2 option to leave dropdown open for multiple selection
        },
    )

    uuid_list_field_checkbox = schema.List(
        title=u"RelationList with Checkboxes storing uuids",
        value_type=schema.Choice(
            vocabulary="example.vocabularies.documents", ),
        required=False,
    )
    directives.widget(
        "uuid_list_field_checkbox",
        CheckBoxFieldWidget,
    )

    uuid_choice_field_ajax_select = schema.Choice(
        title=u"Relationchoice Field with AJAXSelect storing uuids",
        description=u"z3c.relationfield.schema.RelationChoice",
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        required=False,
    )
    directives.widget(
        "uuid_choice_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
        }),
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
        },
    )

    uuid_list_field_ajax_select = schema.List(
        title=u"Relationlist Field with AJAXSelect storing uuids",
        description=u"z3c.relationfield.schema.RelationList",
        value_type=schema.Choice(vocabulary=StaticCatalogVocabulary({
            "portal_type": ["Document", "Event"],
            "review_state":
            "published",
        })),
        required=False,
    )
    directives.widget(
        "uuid_list_field_ajax_select",
        AjaxSelectFieldWidget,
        vocabulary=StaticCatalogVocabulary(
            {
                "portal_type": ["Document", "Event"],
            },
            title_template="{brain.Type}: {brain.Title} at {path}",
        ),  # Custom item rendering
        pattern_options={  # Options for Select2
            "minimumInputLength":
            2,  # - Don't query until at least two characters have been typed
            "ajax": {
                "quietMillis": 500
            },  # - Wait 500ms after typing to make query
            "closeOnSelect":
            False,  # - Leave dropdown open for multiple selection
        },
    )

    # Number fields
    int_field = schema.Int(
        title=u"Integer Field (e.g. 12)",
        description=u"zope.schema.Int",
        required=False,
    )

    float_field = schema.Float(
        title=u"Float field, e.g. 12.7",
        description=u"zope.schema.Float",
        required=False,
    )

    # Text fields
    email_field = Email(
        title=u"Email field",
        description=
        u"A simple input field for a email (plone.schema.email.Email)",
        required=False,
    )

    uri_field = schema.URI(
        title=u"URI field",
        description=u"A simple input field for a URLs (zope.schema.URI)",
        required=False,
    )

    richtext_field = RichText(
        title=u"RichText field",
        description=
        u"This uses a richtext editor. (plone.app.textfield.RichText)",
        max_length=2000,
        required=False,
    )

    sourcetext_field = schema.SourceText(
        title=u"SourceText field",
        description=u"zope.schema.SourceText",
        required=False,
    )

    ascii_field = schema.ASCII(
        title=u"ASCII field",
        description=u"zope.schema.ASCII",
        required=False,
    )

    bytesline_field = schema.BytesLine(
        title=u"BytesLine field",
        description=u"zope.schema.BytesLine",
        required=False,
    )

    asciiline_field = schema.ASCIILine(
        title=u"ASCIILine field",
        description=u"zope.schema.ASCIILine",
        required=False,
    )

    pythonidentifier_field = schema.PythonIdentifier(
        title=u"PythonIdentifier field",
        description=u"zope.schema.PythonIdentifier",
        required=False,
    )

    dottedname_field = schema.DottedName(
        title=u"DottedName field",
        description=u"zope.schema.DottedName",
        required=False,
    )

    # dict_field = schema.Dict(
    #     title=u'Dict field',
    #     description=u"zope.schema.Dict",
    #     required=False,
    #     key_type=schema.TextLine(
    #         title=u'Key',
    #         required=False,
    #     ),
    #     value_type=schema.TextLine(
    #         title=u'Value',
    #         required=False,
    #     ),
    # )

    # vocabularyterms_field = Dict(  # we use the plone.schema field Dict not zope.schema field to use the attribute 'widget'
    #     title=u"Vocabulary terms field",
    #     description=u"plone.schema.Dict field with value_type schema.TextLine and frontend widget 'VocabularyTermsWidget'",
    #     required=False,
    #     key_type=schema.TextLine(
    #         title=u"Key",
    #         required=False,
    #     ),
    #     value_type=schema.TextLine(
    #         title=u"Value",
    #         required=False,
    #     ),
    #     widget="vocabularyterms",  # we use the widget attribute to apply the frontend widget VocabularyWidget
    # )

    # vocabularytermstranslation_field = Dict(  # we use the plone.schema field Dict not zope.schema field to use the attribute 'widget'
    #     title=u"Vocabulary terms field with translations",
    #     description=u"plone.schema.Dict field with value_type Dict and frontend widget 'VocabularyTermsWidget'",
    #     required=False,
    #     key_type=schema.TextLine(
    #         title=u"Key",
    #         required=False,
    #     ),
    #     value_type=Dict(  # we use the plone.schema field Dict not zope.schema field to use the attribute 'widget'
    #         title=u"Term translation",
    #         description=u"plone.schema.Dict field for translations of vocabulary term",
    #         required=True,
    #         key_type=schema.TextLine(
    #             title=u"Key",
    #             required=False,
    #         ),
    #         value_type=schema.TextLine(
    #             title=u"Value",
    #             required=False,
    #         ),
    #     ),
    #     widget="vocabularyterms",  # we use the widget attribute to apply the frontend widget VocabularyWidget
    # )

    # dict_field_with_choice = schema.Dict(
    #     title=u'Dict field with key and value as choice',
    #     description=u"zope.schema.Dict",
    #     required=False,
    #     key_type=schema.Choice(
    #         title=u'Key',
    #         values=[u'One', u'Two', u'Three'],
    #         required=False,
    #         ),
    #     value_type=schema.Set(
    #         title=u'Value',
    #         value_type=schema.Choice(
    #             values=[u'Beginner', u'Advanced', u'Professional'],
    #             ),
    #         required=False,
    #         missing_value={},
    #         ),
    #     )

    datagrid_field = schema.List(
        title=u"Datagrid field",
        description=u"schema.List",
        value_type=DictRow(title=u"Table", schema=IMyRowSchema),
        default=[],
        required=False,
    )
    directives.widget("datagrid_field", DataGridFieldFactory)