geonature.core.gn_meta.schemas

Classes

DatasetActorSchema

This mixin automatically exclude from serialization:

DatasetSchema

This mixin add a cruved field which serialize to a dict "{action: boolean}".

BibliographicReferenceSchema

This mixin automatically exclude from serialization:

AcquisitionFrameworkActorSchema

This mixin automatically exclude from serialization:

AcquisitionFrameworkSchema

This mixin add a cruved field which serialize to a dict "{action: boolean}".

Module Contents

class geonature.core.gn_meta.schemas.DatasetActorSchema(*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}))

  • For SQLAlchemyAutoSchema, all deffered columns

Default marshmallow behaviour is to serialize only fields specified in only. This mixin add these:

  • If they are only Nested fields in only, they are added to serialized fields along with default serialized fields.

  • To serialize Nested fields only and not default serialized fields, add "-" special value to only.

  • To add excluded fields (through metadata or deffered fields) to the serialization in addition to default serialized fields, use “+field_name” syntax.

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=["id"]).dump() -> {"id": 1}
FooSchema(only=["default_excluded_field"]).dump() -> {"default_excluded_field": "test"}
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...}}
FooSchema(only=["-", "relationship"]).dump() -> {"relationship": {OtherSchema...}}
class Meta[source]

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Meta):
        additional = True  # Incompatible types in assignment

Supprimé dans la version 3.0.0b7: Remove strict.

Ajouté dans la version 3.0.0b12: Add unknown.

Modifié dans la version 3.0.0b17: Rename dateformat to datetimeformat.

Ajouté dans la version 3.9.0: Add timeformat.

Modifié dans la version 3.26.0: Deprecate ordered. Field order is preserved by default.

Supprimé dans la version 4.0.0: Remove ordered.

model[source]
load_instance = True[source]
include_fk = True[source]
role[source]
nomenclature_actor_role[source]
organism[source]
make_dataset_actor(data, **kwargs)[source]
class geonature.core.gn_meta.schemas.DatasetSchema(*args, **kwargs)[source]

Bases: geonature.utils.schema.CruvedSchemaMixin, utils_flask_sqla.schema.SmartRelationshipsMixin, geonature.utils.env.MA.SQLAlchemyAutoSchema

This mixin add a cruved field which serialize to a dict « {action: boolean} ».

example: {« C »: False, « R »: True, « U »: True, « V »: False, « E »: True, « D »: False}

The schema must have a __module_code__ property (and optionally a __object_code__property) to indicate from which permissions must be verified. The model must have an has_instance_permission method which take the scope and retrurn a boolean. The cruved field is excluded by default and may be added to serialization with only=[« +cruved »].

class Meta[source]

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Meta):
        additional = True  # Incompatible types in assignment

Supprimé dans la version 3.0.0b7: Remove strict.

Ajouté dans la version 3.0.0b12: Add unknown.

Modifié dans la version 3.0.0b17: Rename dateformat to datetimeformat.

Ajouté dans la version 3.9.0: Add timeformat.

Modifié dans la version 3.26.0: Deprecate ordered. Field order is preserved by default.

Supprimé dans la version 4.0.0: Remove ordered.

model[source]
load_instance = True[source]
include_fk = True[source]
__module_code__ = 'METADATA'[source]
meta_create_date[source]
meta_update_date[source]
cor_dataset_actor[source]
modules[source]
creator[source]
nomenclature_data_type[source]
nomenclature_dataset_objectif[source]
nomenclature_collecting_method[source]
nomenclature_data_origin[source]
nomenclature_source_status[source]
nomenclature_resource_type[source]
cor_territories[source]
acquisition_framework[source]
sources[source]
mobile_app[source]
validate_acquisition_framework_opened(data, **kwargs)[source]

Check if the acquisition framework is opened before creating or updating active status on a dataset.

module_input(item, original, many, **kwargs)[source]
mobile_app_compat(data, original, many, **kwargs)[source]
class geonature.core.gn_meta.schemas.BibliographicReferenceSchema(*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}))

  • For SQLAlchemyAutoSchema, all deffered columns

Default marshmallow behaviour is to serialize only fields specified in only. This mixin add these:

  • If they are only Nested fields in only, they are added to serialized fields along with default serialized fields.

  • To serialize Nested fields only and not default serialized fields, add "-" special value to only.

  • To add excluded fields (through metadata or deffered fields) to the serialization in addition to default serialized fields, use “+field_name” syntax.

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=["id"]).dump() -> {"id": 1}
FooSchema(only=["default_excluded_field"]).dump() -> {"default_excluded_field": "test"}
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...}}
FooSchema(only=["-", "relationship"]).dump() -> {"relationship": {OtherSchema...}}
class Meta[source]

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Meta):
        additional = True  # Incompatible types in assignment

Supprimé dans la version 3.0.0b7: Remove strict.

Ajouté dans la version 3.0.0b12: Add unknown.

Modifié dans la version 3.0.0b17: Rename dateformat to datetimeformat.

Ajouté dans la version 3.9.0: Add timeformat.

Modifié dans la version 3.26.0: Deprecate ordered. Field order is preserved by default.

Supprimé dans la version 4.0.0: Remove ordered.

model[source]
load_instance = True[source]
include_fk = True[source]
acquisition_framework[source]
make_biblio_ref(data, **kwargs)[source]
class geonature.core.gn_meta.schemas.AcquisitionFrameworkActorSchema(*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}))

  • For SQLAlchemyAutoSchema, all deffered columns

Default marshmallow behaviour is to serialize only fields specified in only. This mixin add these:

  • If they are only Nested fields in only, they are added to serialized fields along with default serialized fields.

  • To serialize Nested fields only and not default serialized fields, add "-" special value to only.

  • To add excluded fields (through metadata or deffered fields) to the serialization in addition to default serialized fields, use “+field_name” syntax.

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=["id"]).dump() -> {"id": 1}
FooSchema(only=["default_excluded_field"]).dump() -> {"default_excluded_field": "test"}
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...}}
FooSchema(only=["-", "relationship"]).dump() -> {"relationship": {OtherSchema...}}
class Meta[source]

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Meta):
        additional = True  # Incompatible types in assignment

Supprimé dans la version 3.0.0b7: Remove strict.

Ajouté dans la version 3.0.0b12: Add unknown.

Modifié dans la version 3.0.0b17: Rename dateformat to datetimeformat.

Ajouté dans la version 3.9.0: Add timeformat.

Modifié dans la version 3.26.0: Deprecate ordered. Field order is preserved by default.

Supprimé dans la version 4.0.0: Remove ordered.

model[source]
load_instance = True[source]
include_fk = True[source]
role[source]
nomenclature_actor_role[source]
organism[source]
cor_volets_sinp[source]
make_af_actor(data, **kwargs)[source]
class geonature.core.gn_meta.schemas.AcquisitionFrameworkSchema(*args, **kwargs)[source]

Bases: geonature.utils.schema.CruvedSchemaMixin, utils_flask_sqla.schema.SmartRelationshipsMixin, geonature.utils.env.MA.SQLAlchemyAutoSchema

This mixin add a cruved field which serialize to a dict « {action: boolean} ».

example: {« C »: False, « R »: True, « U »: True, « V »: False, « E »: True, « D »: False}

The schema must have a __module_code__ property (and optionally a __object_code__property) to indicate from which permissions must be verified. The model must have an has_instance_permission method which take the scope and retrurn a boolean. The cruved field is excluded by default and may be added to serialization with only=[« +cruved »].

class Meta[source]

Options object for a Schema.

Example usage:

from marshmallow import Schema


class MySchema(Schema):
    class Meta:
        fields = ("id", "email", "date_created")
        exclude = ("password", "secret_attribute")

A note on type checking

Type checkers will only check the attributes of the Meta <marshmallow.Schema.Meta> class if you explicitly subclass marshmallow.Schema.Meta.

from marshmallow import Schema


class MySchema(Schema):
    # Not checked by type checkers
    class Meta:
        additional = True


class MySchema2(Schema):
    # Type checkers will check attributes
    class Meta(Schema.Meta):
        additional = True  # Incompatible types in assignment

Supprimé dans la version 3.0.0b7: Remove strict.

Ajouté dans la version 3.0.0b12: Add unknown.

Modifié dans la version 3.0.0b17: Rename dateformat to datetimeformat.

Ajouté dans la version 3.9.0: Add timeformat.

Modifié dans la version 3.26.0: Deprecate ordered. Field order is preserved by default.

Supprimé dans la version 4.0.0: Remove ordered.

model[source]
load_instance = True[source]
include_fk = True[source]
__module_code__ = 'METADATA'[source]
meta_create_date[source]
meta_update_date[source]
t_datasets[source]
datasets[source]
bibliographical_references[source]
cor_af_actor[source]
cor_volets_sinp[source]
cor_objectifs[source]
cor_territories[source]
nomenclature_territorial_level[source]
nomenclature_financing_type[source]
creator[source]