How to use the colander.Boolean function in colander

To help you get started, we’ve selected a few colander 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 NLeSC / MAGMa / web / magmaweb / jobquery.py View on Github external
missing=colander.null,
                                       validator=colander.OneOf(['pubchem',
                                                                 'kegg',
                                                                 'hmdb',
                                                                 ]),
                                       name='structure_database'
                                       ))
        schema.add(colander.SchemaNode(colander.Integer(),
                                       missing=colander.null,
                                       validator=colander.Range(min=1),
                                       name='min_refscore'))
        schema.add(colander.SchemaNode(colander.Integer(),
                                       missing=colander.null,
                                       validator=colander.Range(min=1),
                                       name='max_mz'))
        schema.add(colander.SchemaNode(colander.Boolean(),
                                       missing=False,
                                       name='excl_halo'))
        schema.add(colander.SchemaNode(self.File(),
                                       missing=colander.null,
                                       name='ids_file'))
github AppEnlight / appenlight / backend / src / appenlight / validators.py View on Github external
)
    request_id = colander.SchemaNode(
        colander.String(), preparer=shortener_factory(40), missing=""
    )
    server = colander.SchemaNode(
        colander.String(), preparer=shortener_factory(128), missing="unknown"
    )
    date = colander.SchemaNode(
        NonTZDate(), validator=limited_date, missing=deferred_utcnow
    )
    tags = TagSchemaList()


class LogSchemaPermanent(LogSchema):
    date = colander.SchemaNode(NonTZDate(), missing=deferred_utcnow)
    permanent = colander.SchemaNode(colander.Boolean(), missing=False)


class LogListSchema(colander.SequenceSchema):
    """
    Validates format of list of log entries
    """

    log = LogSchema()
    validator = colander.Length(1)


class LogListPermanentSchema(colander.SequenceSchema):
    """
    Validates format of list of log entries
    """
github stefanofontanelli / ColanderAlchemy / colanderalchemy / schema.py View on Github external
type_ = declarative_type()
            else:
                type_ = declarative_type
            log.debug('Column %s: type overridden via declarative: %s.',
                      name, type_)

        elif typedecorator_type is not None:
            if hasattr(typedecorator_type, '__call__'):
                type_ = typedecorator_type()
            else:
                type_ = typedecorator_type
            log.debug('Column %s: type overridden via TypeDecorator: %s.',
                      name, type_)

        elif isinstance(column_type, Boolean):
            type_ = colander.Boolean()

        elif isinstance(column_type, Date):
            type_ = colander.Date()

        elif isinstance(column_type, DateTime):
            type_ = colander.DateTime(default_tzinfo=None)

        elif isinstance(column_type, Enum):
            type_ = colander.String()
            kwargs["validator"] = colander.OneOf(column.type.enums)

        elif isinstance(column_type, Float):
            type_ = colander.Float()

        elif isinstance(column_type, Integer):
            type_ = colander.Integer()
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / schema / __init__.py View on Github external
def schema_type(self) -> SchemaType:
        """Return the schema type."""
        return BooleanType(true_choices=('true', '1'))
github NOAA-ORR-ERD / PyGnome / py_gnome / gnome / persist / monkey_patch_colander.py View on Github external
def apply():
    pass
    # Recover boolean values which were coerced into strings.
    serialize_boolean = getattr(colander.Boolean, 'serialize')

    def patched_boolean_serialization(*args, **kwds):
        result = serialize_boolean(*args, **kwds)

        if result is not colander.null:
            result = result == 'true'

        return result

    setattr(colander.Boolean, 'serialize', patched_boolean_serialization)

    # Recover float values which were coerced into strings.
    serialize_float = getattr(colander.Float, 'serialize')

    def patched_float_serialization(*args, **kwds):
        result = serialize_float(*args, **kwds)
github pudo-attic / grano-old / grano / validation / schema.py View on Github external
def apply_schema(base, schema):
    """ Apply the required attributes of a given schema to an existing
    schema. """
    for attribute in schema.attributes:
        validator = ATTRIBUTE_VALIDATORS[attribute.type]
        missing = attribute.missing
        if validator == colander.Boolean:
            missing = missing or "0"
        base.add(_node(validator(), attribute.name,
                 missing=attribute.missing, empty=attribute.missing))
    return base
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / schema / __init__.py View on Github external
def schema_type(self) -> colander.SchemaType:
        return colander.Boolean(true_choices=('true', '1'))
github mazvv / travelcrm / travelcrm / forms / navigations.py View on Github external
url = colander.SchemaNode(
        colander.String(),
        missing='',
        validator=colander.Length(max=128)
    )
    action = colander.SchemaNode(
        colander.String(),
        validator=colander.Length(max=32)
    )
    icon_cls = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Length(max=32)
    )
    separator_before = colander.SchemaNode(
        colander.Boolean(false_choices=("", "0", "false"), true_choices=("1")),
        missing=False
    )


@colander.deferred
def position_validator(node, kw):
    request = kw.get('request')

    def validator(node, value):
        if value == int(request.params.get('position_id')):
            raise colander.Invalid(
                node,
                _(u'Can not copy to itself'),
            )
    return colander.All(validator,)
github NOAA-ORR-ERD / PyGnome / py_gnome / gnome / environment / gridded_objects_base.py View on Github external
#filename
    #data?
    units = SchemaNode(String())
    time = TimeSchema(
        save_reference=True
    )
    grid = GridSchema(
        save_reference=True
    )
    data_file = FilenameSchema(
        isdatafile=True, test_equal=False, update=False
    )
    grid_file = FilenameSchema(
        isdatafile=True, test_equal=False, update=False
    )
    extrapolation_is_allowed = SchemaNode(Boolean())
    data_start = SchemaNode(LocalDateTime(), read_only=True,
                            validator=convertible_to_seconds)
    data_stop = SchemaNode(LocalDateTime(), read_only=True,
                           validator=convertible_to_seconds)


class VariableSchema(VariableSchemaBase):
    varname = SchemaNode(
        String(), missing=drop, read_only=True
    )


class VectorVariableSchema(VariableSchemaBase):
    varnames = SequenceSchema(
        SchemaNode(String()),
        read_only=True
github Kotti / Kotti / kotti / views / users.py View on Github external
def schema_factory():
        schema = user_schema()
        del schema["active"]
        schema.add(
            colander.SchemaNode(
                colander.Boolean(),
                name="send_email",
                title=_("Send password registration link."),
                default=True,
            )
        )
        return schema