Switch to unified view

a/Allura/allura/lib/validators.py b/Allura/allura/lib/validators.py
1
from bson import ObjectId
1
from bson import ObjectId
2
import formencode as fe
2
import formencode as fe
3
from formencode import validators as fev
3
from formencode import validators as fev
4
from . import helpers as h
4
5
5
class Ming(fev.FancyValidator):
6
class Ming(fev.FancyValidator):
6
7
7
    def __init__(self, cls, **kw):
8
    def __init__(self, cls, **kw):
8
        self.cls = cls
9
        self.cls = cls
...
...
37
    def from_python(self, value, state):
38
    def from_python(self, value, state):
38
        return value
39
        return value
39
40
40
    def validate(self, value, state):
41
    def validate(self, value, state):
41
        return value
42
        return value
43
44
class MaxBytesValidator(fev.FancyValidator):
45
    max=255
46
47
    def _to_python(self, value, state):
48
        value = h.really_unicode(value or '').encode('utf-8')
49
        if len(value) > self.max:
50
            raise fe.Invalid("Please enter a value less than %s bytes long." % self.max, value, state)
51
        return value
52
53
    def from_python(self, value, state):
54
        return h.really_unicode(value or '')