Exemplo n.º 1
0
    class MapperA(PolymorphicMapper):

        id = Integer(read_only=True)
        name = String()
        object_type = String(choices=['event', 'task'])

        __mapper_args__ = {
            'polymorphic_on': object_type,
            'allow_polymorphic_marshal': False,
        }
Exemplo n.º 2
0
    class MapperBase(Mapper):

        __type__ = TestType

        password = String(error_msgs={'must_match': 'Passwords must match'})
        password_confirm = String()

        def validate(self, output):
            if output.password != output.password_confirm:
                self.fields['password'].invalid('must_match')
Exemplo n.º 3
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String()
        age = Integer()

        def validate(self, output):
            if output.name == 'jack' and output.age != 36:
                raise MappingInvalid(
                    {'name': 'wrong age for jack', 'age': 'jack must be 36'})
Exemplo n.º 4
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String(default='my default')
Exemplo n.º 5
0
    class MapperBase(Mapper):

        __type__ = TestType

        id = Integer()
        name = String()
Exemplo n.º 6
0
    class MapperBase(Mapper):

        __type__ = TestType

        id = Integer()
        name = String(name='my_name', source='name')
Exemplo n.º 7
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String(required=False, allow_none=False)
Exemplo n.º 8
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String(required=False)  # allow_none=True is the default
Exemplo n.º 9
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String()  # required=True is default