geonature.core.gn_meta.schemas
Module Contents
Classes
This mixin automatically exclude from serialization: |
|
This mixin add a cruved field which serialize to a dict "{action: boolean}". |
|
This mixin automatically exclude from serialization: |
|
This mixin automatically exclude from serialization: |
|
This mixin add a cruved field which serialize to a dict "{action: boolean}". |
- 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})
)
Adding only Nested fields to
only
will not exclude others fields and serialize specified Nested fields. Adding exclude=True fields toonly
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 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 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})
)
Adding only Nested fields to
only
will not exclude others fields and serialize specified Nested fields. Adding exclude=True fields toonly
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 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})
)
Adding only Nested fields to
only
will not exclude others fields and serialize specified Nested fields. Adding exclude=True fields toonly
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 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 »].