Beispiel #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
Beispiel #2
0
 def load(self, obj):
     if not isinstance(obj, (unicode, type(None))):
         raise ParseError("%r not a unicode object" % obj)
     return obj
Beispiel #3
0
 def load(self, obj):
     if not isinstance(obj, float):
         raise ParseError("Invalid value for Float field: %r" % obj)
     return float(obj)
Beispiel #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)
Beispiel #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
Beispiel #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]
Beispiel #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)