Example #1
0
    def to_python(self, value):
        """Convert our string value to JSON after we load it from the DB"""
        if value in ("", None):
            return None

        try:
            if isinstance(value, basestring):
                return json.loads(value, object_hook=decode_object)
        except ValueError:
            pass

        return value
Example #2
0
File: fields.py Project: hayd/handy
    def to_python(self, value):
        """Convert our string value to JSON after we load it from the DB"""
        if value == "":
            return None

        try:
            if isinstance(value, basestring):
                return json.loads(value, object_hook=decode_object)
        except ValueError:
            pass

        return value
Example #3
0
    def to_python(self, value):
        """Convert our string value to JSON after we load it from the DB"""
        if value in ("", None):
            return None

        try:
            if isinstance(value, (str, unicode)):
                return json.loads(
                    value, object_hook=decode_object if self.pickle else None)
        except ValueError:
            pass

        return value
Example #4
0
 def value_from_datadict(self, data, files, name):
     value = data.get(name, '').strip()
     if value in ['', None]:
         return {}
     return json.loads(value)
Example #5
0
File: fields.py Project: hayd/handy
 def value_from_datadict(self, data, files, name):
     value = data.get(name, '').strip()
     if value in ['', None]:
         return {}
     return json.loads(value)