Contents
anyblok_marshmallow.exceptions.
RegistryNotFound
Bases: Exception
Exception raised when no registry is found to build schema
with_traceback
()Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
anyblok_marshmallow.fields.
Nested
(nested, default=<marshmallow.missing>, exclude=(), only=None, **kwargs)Bases: marshmallow.fields.Nested
Inherit marshmallow fields.Nested
context
The context dictionary for the parent Schema
.
deserialize
(value, attr=None, data=None)Deserialize value
.
Raises: | ValidationError – If an invalid value is passed or if a required value is missing. |
---|
fail
(key, **kwargs)A helper method that simply raises a ValidationError.
get_value
(attr, obj, accessor=None, default=<marshmallow.missing>)Return the value for a given key from an object.
root
Reference to the Schema that this field belongs to even if it is buried in a List. Return None for unbound fields.
schema
Overload the super property to remove cache
it is the only way to propagate the context at each call
serialize
(attr, obj, accessor=None)Pulls the value for the given key from the object, applies the field’s formatting and returns the result.
Parameters: | |
---|---|
Raises: | ValidationError – In case of formatting problem |
anyblok_marshmallow.fields.
File
(default=<marshmallow.missing>, attribute=None, load_from=None, dump_to=None, error=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, missing=<marshmallow.missing>, error_messages=None, **metadata)Bases: marshmallow.fields.Field
context
The context dictionary for the parent Schema
.
deserialize
(value, attr=None, data=None)Deserialize value
.
Raises: | ValidationError – If an invalid value is passed or if a required value is missing. |
---|
fail
(key, **kwargs)A helper method that simply raises a ValidationError.
get_value
(attr, obj, accessor=None, default=<marshmallow.missing>)Return the value for a given key from an object.
root
Reference to the Schema that this field belongs to even if it is buried in a List. Return None for unbound fields.
serialize
(attr, obj, accessor=None)Pulls the value for the given key from the object, applies the field’s formatting and returns the result.
Parameters: | |
---|---|
Raises: | ValidationError – In case of formatting problem |
anyblok_marshmallow.fields.
Text
(default=<marshmallow.missing>, attribute=None, load_from=None, dump_to=None, error=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, missing=<marshmallow.missing>, error_messages=None, **metadata)Bases: marshmallow.fields.String
Simple field use to distinct by the class String and Text
context
The context dictionary for the parent Schema
.
deserialize
(value, attr=None, data=None)Deserialize value
.
Raises: | ValidationError – If an invalid value is passed or if a required value is missing. |
---|
fail
(key, **kwargs)A helper method that simply raises a ValidationError.
get_value
(attr, obj, accessor=None, default=<marshmallow.missing>)Return the value for a given key from an object.
root
Reference to the Schema that this field belongs to even if it is buried in a List. Return None for unbound fields.
serialize
(attr, obj, accessor=None)Pulls the value for the given key from the object, applies the field’s formatting and returns the result.
Parameters: | |
---|---|
Raises: | ValidationError – In case of formatting problem |
anyblok_marshmallow.fields.
JsonCollection
(fieldname=None, keys=None, instance='default', cls_or_instance_type=<class 'marshmallow.fields.String'>, *args, **kwargs)Bases: marshmallow.fields.Field
context
The context dictionary for the parent Schema
.
deserialize
(value, attr=None, data=None)Deserialize value
.
Raises: | ValidationError – If an invalid value is passed or if a required value is missing. |
---|
fail
(key, **kwargs)A helper method that simply raises a ValidationError.
get_value
(attr, obj, accessor=None, default=<marshmallow.missing>)Return the value for a given key from an object.
root
Reference to the Schema that this field belongs to even if it is buried in a List. Return None for unbound fields.
serialize
(attr, obj, accessor=None)Pulls the value for the given key from the object, applies the field’s formatting and returns the result.
Parameters: | |
---|---|
Raises: | ValidationError – In case of formatting problem |
anyblok_marshmallow.fields.
Country
(default=<marshmallow.missing>, attribute=None, load_from=None, dump_to=None, error=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, missing=<marshmallow.missing>, error_messages=None, **metadata)Bases: marshmallow.fields.String
context
The context dictionary for the parent Schema
.
deserialize
(value, attr=None, data=None)Deserialize value
.
Raises: | ValidationError – If an invalid value is passed or if a required value is missing. |
---|
fail
(key, **kwargs)A helper method that simply raises a ValidationError.
get_value
(attr, obj, accessor=None, default=<marshmallow.missing>)Return the value for a given key from an object.
root
Reference to the Schema that this field belongs to even if it is buried in a List. Return None for unbound fields.
serialize
(attr, obj, accessor=None)Pulls the value for the given key from the object, applies the field’s formatting and returns the result.
Parameters: | |
---|---|
Raises: | ValidationError – In case of formatting problem |
anyblok_marshmallow.fields.
Country
(default=<marshmallow.missing>, attribute=None, load_from=None, dump_to=None, error=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, missing=<marshmallow.missing>, error_messages=None, **metadata)Bases: marshmallow.fields.String
context
The context dictionary for the parent Schema
.
deserialize
(value, attr=None, data=None)Deserialize value
.
Raises: | ValidationError – If an invalid value is passed or if a required value is missing. |
---|
fail
(key, **kwargs)A helper method that simply raises a ValidationError.
get_value
(attr, obj, accessor=None, default=<marshmallow.missing>)Return the value for a given key from an object.
root
Reference to the Schema that this field belongs to even if it is buried in a List. Return None for unbound fields.
serialize
(attr, obj, accessor=None)Pulls the value for the given key from the object, applies the field’s formatting and returns the result.
Parameters: | |
---|---|
Raises: | ValidationError – In case of formatting problem |
anyblok_marshmallow.schema.
update_from_kwargs
(*entries)decorator to get temporaly the value in kwargs and put it in schema
Params entries: | array ok entry name to take from the kwargs |
---|
anyblok_marshmallow.schema.
format_fields
(x)remove the anyblok prefix form the field name
anyblok_marshmallow.schema.
ModelConverter
(schema_cls=None)Bases: marshmallow_sqlalchemy.convert.ModelConverter
Overwrite the ModelConverter class of marshmallow-sqlalchemy
The goal if to fix the fieldname, because they are prefixed.
fields_for_model
(Model, **kwargs)Overwrite the method and remove prefix of the field name
anyblok_marshmallow.schema.
TemplateSchema
Bases: object
Base class of Schema generated by SchemaWrapper
OPTIONS_CLASS
alias of marshmallow_sqlalchemy.schema.ModelSchemaOpts
anyblok_marshmallow.schema.
PostLoadSchema
Bases: object
Return the AnyBlok instance from marshmallow deserialize
anyblok_marshmallow.schema.
SchemaWrapper
(*args, **kwargs)Bases: marshmallow.base.SchemaABC
Schema Wrapper to generate marshmallow schema
class MySchema(SchemaWrapper):
model = 'Model.Name'
the wrapper implement the marshmallow.base.SchemaABC abstract class. And call the methods of the marshmallow schema with the same parameter
Some class attributes can be added to improve the schema:
Note
The model and registry are required to generate the schema. they can be defined by class attribute, parameter in the methods (load, loads, validate, dump, dumps) or in the context attribute.
generate_marsmallow_instance
()Generate the real mashmallow-sqlalchemy schema
schema
property to get the real schema