Adapter.native_json

This commit is contained in:
mdipierro
2013-01-21 14:13:05 -06:00
parent 1518cbd16e
commit d15f13dcbd
2 changed files with 21 additions and 17 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.1-alpha.2+timestamp.2013.01.21.14.05.02 Version 2.4.1-alpha.2+timestamp.2013.01.21.14.12.24
+4
View File
@@ -612,6 +612,7 @@ class ConnectionPool(object):
################################################################################### ###################################################################################
class BaseAdapter(ConnectionPool): class BaseAdapter(ConnectionPool):
native_json = 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
@@ -1790,6 +1791,7 @@ class BaseAdapter(ConnectionPool):
else: else:
obj = str(obj) obj = str(obj)
elif fieldtype == 'json': elif fieldtype == 'json':
if not self.native_json:
if have_serializers: if have_serializers:
obj = serializers.json(obj) obj = serializers.json(obj)
elif simplejson: elif simplejson:
@@ -1928,6 +1930,7 @@ class BaseAdapter(ConnectionPool):
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 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):
@@ -4959,6 +4962,7 @@ def cleanup(text):
return text return text
class MongoDBAdapter(NoSQLAdapter): class MongoDBAdapter(NoSQLAdapter):
native_json = True
drivers = ('pymongo',) drivers = ('pymongo',)
uploads_in_blob = True uploads_in_blob = True