Пример #1
0
    'datetime': lambda *a: validators.DateTime(kind="datetime"),
    'float_time': lambda *a: validators.FloatTime(),
    'float': lambda *a: validators.Float(),
    'integer': lambda *a: validators.Int(),
    'selection': lambda *a: validators.Selection(),
    'char': lambda *a: validators.String(),
    'boolean': lambda *a: validators.Bool(),
    'reference': lambda *a: validators.Reference(),
    'binary': lambda *a: validators.Binary(),
    'text': lambda *a: validators.String(),
    'text_tag': lambda *a: validators.String(),
    'many2many': lambda *a: validators.many2many(),
    'one2many': lambda *a: validators.one2many(),
    'many2one': lambda *a: validators.many2one(),
    'email' : lambda *a: validators.Email(),
    'url' : lambda *a: validators.URL(),
    'picture': lambda *a: validators.Binary(),
}

class TinyFormError(formencode.api.Invalid):
    def __init__(self, field, msg, value):
        formencode.api.Invalid.__init__(self, msg, value, state=None, error_list=None, error_dict=None)
        self.field = field

class TinyForm(object):
    """An utility class to convert:

        1. local form data to the server data (throws exception if any)
        2. server data to the local data

    Using validators.
Пример #2
0
 def __init__(self, **attrs):
     super(URL, self).__init__(**attrs)
     self.validator = validators.URL()