Closed tsilva closed 8 years ago
Appier has support for converting a model to a dictionary, however, it has no support for recursively doing so for the model's relations.
Here's a sample solution (checking for relations is not correct):
def map_full(self): cls = self.__class__ map = self.map() for name, value in appier.legacy.items(map): _definition = cls.definition_n(name) _type = _definition.get("type", None) if not _type: continue type_s = str(_type) if type_s == "<class 'appier.typesf._Reference'>": value = getattr(self, name) map[name] = value.map_full() elif type_s == "<class 'appier.typesf._References'>": value = getattr(self, name) map[name] = [_value.map_full() for _value in value] return map
Description
Appier has support for converting a model to a dictionary, however, it has no support for recursively doing so for the model's relations.
Solution
Here's a sample solution (checking for relations is not correct):