<s> """<STR_LIT>""" <EOL> from google . appengine . ext import db <EOL> from kay . utils . forms import ValidationError <EOL> from kay . utils . forms . modelform import ModelForm <EOL> class MaxLengthValidator ( object ) : <EOL> def __init__ ( self , length ) : <EOL> self . length = length <EOL> def __call__ ( self , val ) : <EOL> if len ( val ) > self . length : <EOL> raise ValidationError ( "<STR_LIT>" ) <EOL> return True <EOL> class TestModel ( db . Model ) : <EOL> number = db . IntegerProperty ( required = True ) <EOL> data_field = db . StringProperty ( required = True , <EOL> validator = MaxLengthValidator ( <NUM_LIT:20> ) ) <EOL> is_active = db . BooleanProperty ( required = True ) <EOL> string_list_field = db . StringListProperty ( required = True ) <EOL> class TestModel2 ( db . Model ) : <EOL> number = db . IntegerProperty ( required = True ) <EOL> data_field = db . StringProperty ( required = True , <EOL> validator = MaxLengthValidator ( <NUM_LIT:20> ) ) <EOL> is_active = db . BooleanProperty ( required = True ) <EOL> string_list_field = db . StringListProperty ( required = True ) <EOL> class TestModelForm ( ModelForm ) : <EOL> csrf_protected = False <EOL> class Meta ( ) : <EOL> model = TestModel <EOL> def __init__ ( self , instance = None , initial = None ) : <EOL> super ( TestModelForm , self ) . __init__ ( instance , initial ) <EOL> self . string_list_field . min_size = <NUM_LIT:1> <EOL> class JsonTestModel ( db . Model ) : <EOL> s = db . StringProperty ( ) <EOL> i = db . IntegerProperty ( ) <EOL> b = db . BooleanProperty ( ) <EOL> l = db . StringListProperty ( ) <EOL> r = db . ReferenceProperty ( ) <EOL> class ModelFormTestModel ( db . Model ) : <EOL> s_name = db . StringProperty ( ) <EOL> zip_code = db . StringProperty ( ) <EOL> addr = db . StringProperty ( ) <EOL> class ModelFormTestForm ( ModelForm ) : <EOL> csrf_protected = False <EOL> class Meta : <EOL> model = ModelFormTestModel <EOL> fields = ( '<STR_LIT>' ) <EOL> class ValidationTestModel ( db . Model ) : <EOL> slist = db . StringListProperty ( ) <EOL> class ValidationTestForm ( ModelForm ) : <EOL> csrf_protected = False <EOL> class Meta : <EOL> model = ValidationTestModel <EOL> def context_validate ( self , data ) : <EOL> raise ValidationError ( "<STR_LIT>" ) </s>
