AttributeError during deserialization
sergray opened this issue · 2 comments
sergray commented
Hi @SVilgelm
Thank you for implementing propagation of dump mode for #80
I have found the following problem after upgrade during execution of the tests:
AttributeError: 'NoneType' object has no attribute '__propagate_dump_mode__'
Example bellow reproduces it:
from marshmallow import fields
from marshmallow_objects import Model, NestedModel
class Person(Model):
name = fields.String()
age = fields.Integer()
class Company(Model):
name = fields.String()
owner = NestedModel(Person, allow_none=True)
Company.load({'name': 'ACME', 'owner': None}).dump()
It occurs in
marshmallow_objects/models.py in __propagate_dump_mode__(self, value)
158 for name, field in self.__schema__.fields.items():
159 if isinstance(field, fields.Nested):
--> 160 getattr(self, name).__propagate_dump_mode__(value)
161
162 @contextlib.contextmanager
AttributeError: 'NoneType' object has no attribute '__propagate_dump_mode__'
SVilgelm commented
Fixed in 2.2.1: https://pypi.org/project/marshmallow-objects/2.2.1/