better native_json naming convention
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.9.9-stable+timestamp.2014.09.12.11.36.19
|
Version 2.9.9-stable+timestamp.2014.09.12.20.28.40
|
||||||
|
|||||||
+6
-7
@@ -720,7 +720,7 @@ class BaseAdapter(ConnectionPool):
|
|||||||
|
|
||||||
__metaclass__ = AdapterMeta
|
__metaclass__ = AdapterMeta
|
||||||
|
|
||||||
native_json = False
|
driver_auto_json_loads = False
|
||||||
driver = None
|
driver = None
|
||||||
driver_name = None
|
driver_name = None
|
||||||
drivers = () # list of drivers from which to pick
|
drivers = () # list of drivers from which to pick
|
||||||
@@ -2174,8 +2174,8 @@ class BaseAdapter(ConnectionPool):
|
|||||||
def parse_double(self, value, field_type):
|
def parse_double(self, value, field_type):
|
||||||
return float(value)
|
return float(value)
|
||||||
|
|
||||||
def parse_json(self, value, field_type):
|
def parse_json(self, value, field_type):
|
||||||
if not self.native_json:
|
if not self.driver_auto_json_loads:
|
||||||
if not isinstance(value, basestring):
|
if not isinstance(value, basestring):
|
||||||
raise RuntimeError('json data not a string')
|
raise RuntimeError('json data not a string')
|
||||||
if isinstance(value, unicode):
|
if isinstance(value, unicode):
|
||||||
@@ -2924,7 +2924,7 @@ class PostgreSQLAdapter(BaseAdapter):
|
|||||||
else: supports_json = None
|
else: supports_json = None
|
||||||
if supports_json:
|
if supports_json:
|
||||||
self.types["json"] = "JSON"
|
self.types["json"] = "JSON"
|
||||||
self.native_json = True
|
self.driver_auto_json_loads = True
|
||||||
else: LOGGER.debug("Your database version does not support the JSON data type (using TEXT instead)")
|
else: LOGGER.debug("Your database version does not support the JSON data type (using TEXT instead)")
|
||||||
|
|
||||||
def LIKE(self, first, second):
|
def LIKE(self, first, second):
|
||||||
@@ -5702,7 +5702,6 @@ def cleanup(text):
|
|||||||
|
|
||||||
|
|
||||||
class MongoDBAdapter(NoSQLAdapter):
|
class MongoDBAdapter(NoSQLAdapter):
|
||||||
native_json = True
|
|
||||||
drivers = ('pymongo', )
|
drivers = ('pymongo', )
|
||||||
|
|
||||||
uploads_in_blob = False
|
uploads_in_blob = False
|
||||||
@@ -5725,7 +5724,7 @@ class MongoDBAdapter(NoSQLAdapter):
|
|||||||
'reference': long,
|
'reference': long,
|
||||||
'list:string': list,
|
'list:string': list,
|
||||||
'list:integer': list,
|
'list:integer': list,
|
||||||
'list:reference': list,
|
'list:reference': list,
|
||||||
}
|
}
|
||||||
|
|
||||||
error_messages = {"javascript_needed": "This must yet be replaced" +
|
error_messages = {"javascript_needed": "This must yet be replaced" +
|
||||||
@@ -7360,7 +7359,7 @@ def sqlhtml_validators(field):
|
|||||||
if field_type in (('string', 'text', 'password')):
|
if field_type in (('string', 'text', 'password')):
|
||||||
requires.append(validators.IS_LENGTH(field_length))
|
requires.append(validators.IS_LENGTH(field_length))
|
||||||
elif field_type == 'json':
|
elif field_type == 'json':
|
||||||
requires.append(validators.IS_EMPTY_OR(validators.IS_JSON(native_json=field.db._adapter.native_json)))
|
requires.append(validators.IS_EMPTY_OR(validators.IS_JSON()))
|
||||||
elif field_type == 'double' or field_type == 'float':
|
elif field_type == 'double' or field_type == 'float':
|
||||||
requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100))
|
requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100))
|
||||||
elif field_type == 'integer':
|
elif field_type == 'integer':
|
||||||
|
|||||||
+6
-2
@@ -372,14 +372,18 @@ class IS_JSON(Validator):
|
|||||||
if self.native_json:
|
if self.native_json:
|
||||||
simplejson.loads(value) # raises error in case of malformed json
|
simplejson.loads(value) # raises error in case of malformed json
|
||||||
return (value, None) # the serialized value is not passed
|
return (value, None) # the serialized value is not passed
|
||||||
return (simplejson.loads(value), None)
|
else:
|
||||||
|
return (simplejson.loads(value), None)
|
||||||
except JSONErrors:
|
except JSONErrors:
|
||||||
return (value, translate(self.error_message))
|
return (value, translate(self.error_message))
|
||||||
|
|
||||||
def formatter(self,value):
|
def formatter(self,value):
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
return simplejson.dumps(value)
|
if self.native_json:
|
||||||
|
return value
|
||||||
|
else:
|
||||||
|
return simplejson.dumps(value)
|
||||||
|
|
||||||
|
|
||||||
class IS_IN_SET(Validator):
|
class IS_IN_SET(Validator):
|
||||||
|
|||||||
Reference in New Issue
Block a user