src.utils_flask_sqla_geo.utils

Module Contents

Classes

JsonifiableGenerator

Inherite from list, so compatible with JSONEncoder, but must be initialized

GeneratorField

As marshmallow List field, but if value is not a list (e.g. map or generator),

Functions

geojsonify(*args, **kwargs)

class src.utils_flask_sqla_geo.utils.JsonifiableGenerator(gen)[source]

Bases: list

Inherite from list, so compatible with JSONEncoder, but must be initialized with a generator. Implement __bool__ as used by JSONEncoder.

__repr__[source]
__iter__()[source]

Implement iter(self).

__bool__()[source]
class src.utils_flask_sqla_geo.utils.GeneratorField(cls_or_instance: Field | type, **kwargs)[source]

Bases: marshmallow.fields.List

As marshmallow List field, but if value is not a list (e.g. map or generator), return a JsonifiableGenerator instead of a list.

_serialize(value, attr, obj, **kwargs)[source]

Serializes value to a basic Python datatype. Noop by default. Concrete Field classes should implement this method.

Example:

class TitleCase(Field):
    def _serialize(self, value, attr, obj, **kwargs):
        if not value:
            return ''
        return str(value).title()
Paramètres:
  • value – The value to be serialized.

  • attr (str) – The attribute or key on the object to be serialized.

  • obj (object) – The object the value was pulled from.

  • kwargs (dict) – Field-specific keyword arguments.

Renvoie:

The serialized value

src.utils_flask_sqla_geo.utils.geojsonify(*args, **kwargs)[source]