class MyMapper(lion.Mapper): _factory = Obj s = lion.StrField() s_none = lion.StrField() s_skip_none = lion.StrField(condition=lion.skip_none) s_skip_empty = lion.StrField(condition=lion.skip_empty) stringify = lion.StrField()
class SubL(lion.Mapper): w = lion.IntField() x = lion.MapperMethodField() y = lion.StrField() z = lion.IntField() def get_x(self, obj): return obj.x + 10
class ComplexL(lion.Mapper): foo = lion.StrField() bar = lion.Field(getter=lion.getters.call_method) sub = lion.MapperField(SubL) subs = lion.ListField(SubL)
class FooMapper(lion.Mapper): name = lion.StrField() value = lion.IntField() bars = lion.ListField(BarMapper)
class BarMapper(lion.Mapper): name = lion.StrField() x = lion.IntField() y = lion.FloatField() z = lion.Field(condition=lion.skip_none)
class SthMapper(lion.Mapper): _factory = Obj title = lion.StrField()
class NodeMapper(lion.Mapper): _factory = Node id = lion.UUIDField() title = lion.StrField() parent = lion.MapperField('self', condition=lion.skip_none) children = lion.ListField('self', condition=lion.skip_empty)
class ProjectMapper(lion.Mapper): _factory = Project id = lion.UUIDField() title = lion.StrField() logo = lion.MapperField(LogoMapper, condition=lion.skip_none)
class CompanyMapper(lion.Mapper): _factory = Company id = lion.UUIDField() title = lion.StrField() logo = lion.MapperField(LogoMapper, condition=lion.skip_none)
class LogoMapper(lion.Mapper): _factory = Logo url = lion.StrField() width = lion.IntField() height = lion.IntField()