:py:mod:`ref_geo.schemas` ========================= .. py:module:: ref_geo.schemas Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: ref_geo.schemas.AreaTypeSchema ref_geo.schemas.AreaSchema ref_geo.schemas.MunicipalitySchema .. py:class:: AreaTypeSchema(*args, **kwargs) Bases: :py:obj:`utils_flask_sqla.schema.SmartRelationshipsMixin`, :py:obj:`ref_geo.env.ma.SQLAlchemyAutoSchema` This mixin automatically exclude from serialization: * Nested, RelatedList and Related fields * all fields with exclude=True in their metadata (e.g. ``fields.String(metadata={'exclude': True})``) Adding only Nested fields to ``only`` will not exclude others fields and serialize specified Nested fields. Adding exclude=True fields to ``only`` will serialize only specified fields (default marshmallow behaviour). You can use '+field_name' syntax on `only` to serialize default excluded fields (with metadata exclude = True) without other fields. Examples : .. code-block:: python class FooSchema(SmartRelationshipsMixin): id = fields.Int() name = field.Str() default_excluded_field = fields.Str(metadata={"exclude": True}) relationship = fields.Nested(OtherSchema) # or field.RelatedList() / field.Related() FooSchema().dump() -> {"id": 1, "name": "toto" } FooSchema(only=["+default_excluded_field"]).dump() -> {"id": 1, "name": "toto", default_excluded_field: "test" } FooSchema(only=["relationship"]).dump() -> {"id": 1, "name": "toto", relationship : {OtherSchema...} } FooSchema(only=["id", "relationship"]).dump() -> {"id": 1, relationship : {OtherSchema...} } .. py:class:: Meta .. py:attribute:: model .. py:attribute:: include_fk :value: True .. py:attribute:: load_instance :value: True .. py:class:: AreaSchema(*args, **kwargs) Bases: :py:obj:`utils_flask_sqla.schema.SmartRelationshipsMixin`, :py:obj:`utils_flask_sqla_geo.schema.GeoAlchemyAutoSchema` This mixin automatically exclude from serialization: * Nested, RelatedList and Related fields * all fields with exclude=True in their metadata (e.g. ``fields.String(metadata={'exclude': True})``) Adding only Nested fields to ``only`` will not exclude others fields and serialize specified Nested fields. Adding exclude=True fields to ``only`` will serialize only specified fields (default marshmallow behaviour). You can use '+field_name' syntax on `only` to serialize default excluded fields (with metadata exclude = True) without other fields. Examples : .. code-block:: python class FooSchema(SmartRelationshipsMixin): id = fields.Int() name = field.Str() default_excluded_field = fields.Str(metadata={"exclude": True}) relationship = fields.Nested(OtherSchema) # or field.RelatedList() / field.Related() FooSchema().dump() -> {"id": 1, "name": "toto" } FooSchema(only=["+default_excluded_field"]).dump() -> {"id": 1, "name": "toto", default_excluded_field: "test" } FooSchema(only=["relationship"]).dump() -> {"id": 1, "name": "toto", relationship : {OtherSchema...} } FooSchema(only=["id", "relationship"]).dump() -> {"id": 1, relationship : {OtherSchema...} } .. py:class:: Meta .. py:attribute:: model .. py:attribute:: include_fk :value: True .. py:attribute:: load_instance :value: True .. py:attribute:: feature_geometry :value: 'geom_4326' .. py:attribute:: area_type .. py:class:: MunicipalitySchema(*args, **kwargs) Bases: :py:obj:`utils_flask_sqla.schema.SmartRelationshipsMixin`, :py:obj:`utils_flask_sqla_geo.schema.GeoAlchemyAutoSchema` This mixin automatically exclude from serialization: * Nested, RelatedList and Related fields * all fields with exclude=True in their metadata (e.g. ``fields.String(metadata={'exclude': True})``) Adding only Nested fields to ``only`` will not exclude others fields and serialize specified Nested fields. Adding exclude=True fields to ``only`` will serialize only specified fields (default marshmallow behaviour). You can use '+field_name' syntax on `only` to serialize default excluded fields (with metadata exclude = True) without other fields. Examples : .. code-block:: python class FooSchema(SmartRelationshipsMixin): id = fields.Int() name = field.Str() default_excluded_field = fields.Str(metadata={"exclude": True}) relationship = fields.Nested(OtherSchema) # or field.RelatedList() / field.Related() FooSchema().dump() -> {"id": 1, "name": "toto" } FooSchema(only=["+default_excluded_field"]).dump() -> {"id": 1, "name": "toto", default_excluded_field: "test" } FooSchema(only=["relationship"]).dump() -> {"id": 1, "name": "toto", relationship : {OtherSchema...} } FooSchema(only=["id", "relationship"]).dump() -> {"id": 1, relationship : {OtherSchema...} } .. py:class:: Meta .. py:attribute:: model .. py:attribute:: include_fk :value: True .. py:attribute:: load_instance :value: True