The idea is to create model.set_data() method that will populate model's fields from dictionary.
In case, when model has relation with other model (fields.Model) and the the data of related model is provided as a dict in the corresponding key of dict that is passed to "root" model's set_data(), then "root" model should try to transform this related model's data to the related model instance.
In case, when model has relation with other model (fields.Collection) and the the data of related model is provided as a list (any sequential type, actually) in the corresponding key of dict that is passed to "root" model's set_data(), then "root" model should try to transform this related model's data to the collection of related model instances.
In case, when when there are any parasite data in dict that was passed to model.set_data(), exception should be raised.
Notes: Current logic should work for DomainModel.__init__() as well.
The idea is to create
model.set_data()
method that will populate model's fields from dictionary.fields.Model
) and the the data of related model is provided as adict
in the corresponding key ofdict
that is passed to "root" model'sset_data()
, then "root" model should try to transform this related model's data to the related model instance.fields.Collection
) and the the data of related model is provided as alist
(any sequential type, actually) in the corresponding key ofdict
that is passed to "root" model'sset_data()
, then "root" model should try to transform this related model's data to the collection of related model instances.dict
that was passed tomodel.set_data()
, exception should be raised.Notes: Current logic should work for
DomainModel.__init__()
as well.Example: