Permalink
Browse files

Merge "Sync jsonutils from openstack-common"

  • Loading branch information...
2 parents 4a4ab10 + 5adb018 commit 6c5b233c505f66bcd70cd87c1bf1fa5804756301 Jenkins committed with openstack-gerrit Jul 19, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 keystone/openstack/common/jsonutils.py
View
10 keystone/openstack/common/jsonutils.py
@@ -39,6 +39,8 @@
import json
import xmlrpclib
+from keystone.openstack.common import timeutils
+
def to_primitive(value, convert_instances=False, level=0):
"""Convert a complex object into primitives.
@@ -101,7 +103,7 @@ def to_primitive(value, convert_instances=False, level=0):
level=level)
return o
elif isinstance(value, datetime.datetime):
- return str(value)
+ return timeutils.strtime(value)
elif hasattr(value, 'iteritems'):
return to_primitive(dict(value.iteritems()),
convert_instances=convert_instances,
@@ -130,11 +132,15 @@ def loads(s):
return json.loads(s)
+def load(s):
+ return json.load(s)
+
+
try:
import anyjson
except ImportError:
pass
else:
anyjson._modules.append((__name__, 'dumps', TypeError,
- 'loads', ValueError))
+ 'loads', ValueError, 'load'))
anyjson.force_implementation(__name__)

0 comments on commit 6c5b233

Please sign in to comment.