How to use the guillotina.schema.interfaces.IField function in guillotina

To help you get started, we’ve selected a few guillotina 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 / guillotina / guillotina / schema / interfaces.py View on Github external
description=_(
            """The field default value may be None or a legal
                        field value"""
        ),
    )


class IFloat(IMinMax, IField):
    """Field containing a Float."""


class IDecimal(IMinMax, IField):
    """Field containing a Decimal."""


class IDatetime(IMinMax, IField):
    """Field containing a DateTime."""


class IDate(IMinMax, IField):
    """Field containing a date."""


class ITimedelta(IMinMax, IField):
    """Field containing a timedelta."""


class ITime(IMinMax, IField):
    """Field containing a time."""


def _is_field(value):
github plone / guillotina / guillotina / schema / interfaces.py View on Github external
max_length = Int(
        title=_("Maximum length"),
        description=_(
            """
        Value after whitespace processing cannot have greater
        or equal than `max_length` characters (if a string type) or
        elements (if another sequence type). If `max_length` is
        ``None``, there is no maximum."""
        ),
        required=False,
        min=0,  # needs to be a positive number
        default=None,
    )


class IInterfaceField(IField):
    """Fields with a value that is an interface (implementing
    zope.interface.Interface)."""


class IBool(IField):
    """Boolean Field."""

    default = Bool(
        title=_("Default Value"),
        description=_(
            """The field default value may be None or a legal
                        field value"""
        ),
    )
github plone / guillotina / guillotina / schema / interfaces.py View on Github external
object = Attribute("The object containing the field")


class IFieldUpdatedEvent(IFieldEvent):
    """
    A field has been modified

    Subscribers will get the old and the new value together with the field
    """

    old_value = Attribute("The value of the field before modification")

    new_value = Attribute("The value of the field after modification")


class IJSONField(IField):
    """A text field that stores A JSON."""

    json_schema = Attribute("json_schema", _("The JSON schema string serialization."))


class IUnionField(IField):
    """
    A field that can be one of multiple types.
github plone / guillotina / guillotina / schema / interfaces.py View on Github external
)


class IFloat(IMinMax, IField):
    """Field containing a Float."""


class IDecimal(IMinMax, IField):
    """Field containing a Decimal."""


class IDatetime(IMinMax, IField):
    """Field containing a DateTime."""


class IDate(IMinMax, IField):
    """Field containing a date."""


class ITimedelta(IMinMax, IField):
    """Field containing a timedelta."""


class ITime(IMinMax, IField):
    """Field containing a time."""


def _is_field(value):
    if not IField.providedBy(value):
        return False
    return True
github plone / guillotina / guillotina / schema / interfaces.py View on Github external
"""Field containing a Decimal."""


class IDatetime(IMinMax, IField):
    """Field containing a DateTime."""


class IDate(IMinMax, IField):
    """Field containing a date."""


class ITimedelta(IMinMax, IField):
    """Field containing a timedelta."""


class ITime(IMinMax, IField):
    """Field containing a time."""


def _is_field(value):
    if not IField.providedBy(value):
        return False
    return True


def _fields(values):
    for value in values:
        if not _is_field(value):
            return False
    return True
github plone / guillotina / guillotina / schema / interfaces.py View on Github external
zope.interface.Interface)."""


class IBool(IField):
    """Boolean Field."""

    default = Bool(
        title=_("Default Value"),
        description=_(
            """The field default value may be None or a legal
                        field value"""
        ),
    )


class IBytes(IMinMaxLen, IIterable, IField):
    """Field containing a byte string (like the python str).

    The value might be constrained to be with length limits.
    """


class IText(IMinMaxLen, IIterable, IField):
    """Field containing a unicode string."""


INativeString = IText


class IASCII(INativeString):
    """Field containing a 7-bit ASCII string. No characters > DEL
    (chr(127)) are allowed
github plone / guillotina / guillotina / json / serialize_schema_field.py View on Github external
# For 'default', 'missing_value' etc, we want to validate against
            # the imported field type itself, not the field type of the
            # attribute
            if (
                element_name in self.field_type_attributes
                or element_name in self.non_validated_field_type_attributes
            ):
                attribute_field = field

            text = None
            if isinstance(value, bytes):
                text = value.decode("utf-8")
            elif isinstance(value, str):
                text = value
            elif IField.providedBy(value):
                serializer = get_multi_adapter((value, field, self.request), ISchemaFieldSerializeToJson)
                text = serializer.serialize()
                if "properties" in text:
                    text = text["properties"]
            elif value is not None and (force or value != field.missing_value):
                text = json_compatible(value)

            if text:
                if attribute_name == "value_type":
                    attribute_name = "items"
                result[attribute_name] = text
        if result["type"] == "object":
            if IJSONField.providedBy(field):
                result.update(field.json_schema)
            if IDict.providedBy(field):
                if "properties" not in result:
github plone / guillotina / guillotina / json / deserialize_value.py View on Github external
@configure.value_deserializer(for_=IField)
def default_converter(field, value, context=None):
    return value
github plone / guillotina / guillotina / schema / interfaces.py View on Github external
Subscribers will get the old and the new value together with the field
    """

    old_value = Attribute("The value of the field before modification")

    new_value = Attribute("The value of the field after modification")


class IJSONField(IField):
    """A text field that stores A JSON."""

    json_schema = Attribute("json_schema", _("The JSON schema string serialization."))


class IUnionField(IField):
    """
    A field that can be one of multiple types.
github plone / guillotina / guillotina / schema / interfaces.py View on Github external
or equal than `max_length` characters (if a string type) or
        elements (if another sequence type). If `max_length` is
        ``None``, there is no maximum."""
        ),
        required=False,
        min=0,  # needs to be a positive number
        default=None,
    )


class IInterfaceField(IField):
    """Fields with a value that is an interface (implementing
    zope.interface.Interface)."""


class IBool(IField):
    """Boolean Field."""

    default = Bool(
        title=_("Default Value"),
        description=_(
            """The field default value may be None or a legal
                        field value"""
        ),
    )


class IBytes(IMinMaxLen, IIterable, IField):
    """Field containing a byte string (like the python str).

    The value might be constrained to be with length limits.
    """