How can we chain Marshmallow hooks when you use schema inheritance?
Suppose the following "dumb" example:
from marshmallow import Schema, fields, post_load
class PersonSchema(Schema):
name = fields.Str()
@post_load
def post_load(self, data, **_):
data["name"] = data["name"].capitalize()
return data
class EmployeeSchema(PersonSchema):
title = fields.Str()
@post_load
def post_load(self, data, **_):
data["title"] = data["title"].upper()
return data
EmployeeSchema().load({"name": "john", "title": "ceo"})
# {"name": "john", "title": "CEO"}
In this example, only the subclassed hook was triggered. How do you make the parent hook trigger as well on deserialization, in this case?
How can we chain
Marshmallowhooks when you use schema inheritance?Suppose the following "dumb" example:
In this example, only the subclassed hook was triggered. How do you make the parent hook trigger as well on deserialization, in this case?