Exemplo n.º 1
0
 def load(self, obj):
     parsed = self._field_type.load(obj)
     if parsed not in self.values and parsed is not None:
         raise ParseError(
             "Parsed value %r not in allowed value of Enum(%r)" %
             (parsed, tuple(self.values)))
     return parsed
Exemplo n.º 2
0
 def load(self, obj):
     if not isinstance(obj, (unicode, type(None))):
         raise ParseError("%r not a unicode object" % obj)
     return obj
Exemplo n.º 3
0
 def load(self, obj):
     if not isinstance(obj, float):
         raise ParseError("Invalid value for Float field: %r" % obj)
     return float(obj)
Exemplo n.º 4
0
 def load(self, obj):
     if obj not in self.VALUE_MAP:
         raise ParseError("Invalid value for Boolean field: %r" % obj)
     return bool(obj)
Exemplo n.º 5
0
 def load(self, obj):
     if not isinstance(obj,
                       (int, long, type(None))) or isinstance(obj, bool):
         raise ParseError("%r is not a valid Integer" % (obj, ))
     return obj
Exemplo n.º 6
0
 def load(self, obj):
     if not isinstance(obj, list):
         raise ParseError("%r is not a list object" % obj)
     return [self.field_type.load(o) for o in obj]
Exemplo n.º 7
0
 def load(self, obj, **kwargs):
     if not isinstance(obj, (float, int, long)):
         raise ParseError("Invalid value for Float field: %r" % obj)
     return float(obj)