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

        __type__ = TestType

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

        __type__ = TestType

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

        __type__ = TestType

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

        __type__ = TestType

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

        __type__ = TestType

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

        __type__ = TestType

        name = String()  # required=True is default