Example #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,
        }
Example #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')
Example #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'})
Example #4
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String(default='my default')
Example #5
0
    class MapperBase(Mapper):

        __type__ = TestType

        id = Integer()
        name = String()
Example #6
0
    class MapperBase(Mapper):

        __type__ = TestType

        id = Integer()
        name = String(name='my_name', source='name')
Example #7
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String(required=False, allow_none=False)
Example #8
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String(required=False)  # allow_none=True is the default
Example #9
0
    class MapperBase(Mapper):

        __type__ = TestType

        name = String()  # required=True is default