geonature.core.gn_synthese.schemas

Module Contents

Classes

ReportTypeSchema

SQLAlchemyAutoSchema that automatically generates marshmallow fields

ReportSchema

This mixin automatically exclude from serialization:

SourceSchema

SQLAlchemyAutoSchema that automatically generates marshmallow fields

SyntheseConverter

Class that converts a SQLAlchemy model into a dictionary of corresponding

SyntheseSchema

This mixin automatically exclude from serialization:

class geonature.core.gn_synthese.schemas.ReportTypeSchema(*args, **kwargs)[source]

Bases: geonature.utils.env.ma.SQLAlchemyAutoSchema

SQLAlchemyAutoSchema that automatically generates marshmallow fields from a SQLAlchemy model’s or table’s column. Uses the scoped session from Flask-SQLAlchemy by default.

See marshmallow_sqlalchemy.SQLAlchemyAutoSchema for more details on the SQLAlchemyAutoSchema API.

class Meta[source]
model[source]
class geonature.core.gn_synthese.schemas.ReportSchema(*args, **kwargs)[source]

Bases: utils_flask_sqla.schema.SmartRelationshipsMixin, geonature.utils.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 :

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...} }
class Meta[source]
model[source]
report_type[source]
user[source]
class geonature.core.gn_synthese.schemas.SourceSchema(*args, **kwargs)[source]

Bases: geonature.utils.env.ma.SQLAlchemyAutoSchema

SQLAlchemyAutoSchema that automatically generates marshmallow fields from a SQLAlchemy model’s or table’s column. Uses the scoped session from Flask-SQLAlchemy by default.

See marshmallow_sqlalchemy.SQLAlchemyAutoSchema for more details on the SQLAlchemyAutoSchema API.

class Meta[source]
model[source]
load_instance = True[source]
module_url[source]
class geonature.core.gn_synthese.schemas.SyntheseConverter(schema_cls=None)[source]

Bases: pypnnomenclature.utils.NomenclaturesConverter, utils_flask_sqla_geo.schema.GeoModelConverter

Class that converts a SQLAlchemy model into a dictionary of corresponding marshmallow Fields <marshmallow.fields.Field>.

class geonature.core.gn_synthese.schemas.SyntheseSchema(*args, **kwargs)[source]

Bases: utils_flask_sqla.schema.SmartRelationshipsMixin, 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 :

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...} }
class Meta[source]
model[source]
exclude = ('the_geom_4326_geojson',)[source]
include_fk = True[source]
load_instance = True[source]
sqla_session[source]
feature_id = 'id_synthese'[source]
feature_geometry = 'the_geom_4326'[source]
model_converter[source]
the_geom_4326[source]
the_geom_authorized[source]
source[source]
module[source]
dataset[source]
habitat[source]
digitiser[source]
cor_observers[source]
medias[source]
areas[source]
area_attachment[source]
validations[source]
last_validation[source]
reports[source]