INNER CODE UNIT · Python
map_to_field
Scille/umongo · src/umongo/abstract.py:40
def map_to_field(self, func):
"""Apply a function to every field in the schema
>>> def func(mongo_path, path, field):
... pass
"""
for name, field in self.fields.items():
mongo_path = field.attribute or name
func(mongo_path, name, field)
if hasattr(field, "map_to_field"):
field.map_to_field(mongo_path, name, func)
def as_marshmallow_schema(self):
"""Return a pure-marshmallow version of this schema class"""
# Use a cache to avoid generating several times the same schema
if self._ma_schema is not None:
return self._ma_schema