Commit 22d7df93 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

Use the appropriate item mapper in RelationMapper.serialize()

Instead of duplicating the logic of serialization of items in this
method, we now rely on a dedicate "jsonschema.item" mapper (properly
selected with relation information) to serialize each item of the
relation.
parent 3a0223d5a4d1
...@@ -527,8 +527,11 @@ class RelationMapper(_RelationMapper): ...@@ -527,8 +527,11 @@ class RelationMapper(_RelationMapper):
raise ValidationError(entity, {self.rtype: msg}) raise ValidationError(entity, {self.rtype: msg})
return {self.orm_rtype: values} return {self.orm_rtype: values}
def serialize(self, entities): def serialize(self, related_entities):
return [{"id": text_type(x.eid)} for x in entities] item_mapper = self.select_mapper(
'jsonschema.item',
rtype=self.rtype, role=self.role, **self.cw_extra_kwargs)
return [item_mapper.serialize(entity) for entity in related_entities]
class ETypeRelationItemMapper(BaseRelationMapper): class ETypeRelationItemMapper(BaseRelationMapper):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment