summaryrefslogtreecommitdiffstats
path: root/openstack/common/jsonutils.py
Commit message (Collapse)AuthorAgeFilesLines
* Add missing convert_instances arg.Russell Bryant2012-07-181-1/+3
| | | | | | | | When calling jsonutils.to_primitive() recursively, the convert_instances argument should be passed along. This change fixes one place where it was not. Change-Id: I536e1ca05bb4e613fba71298797879587e8b4b00
* Track to_primitive() depth after iteritems().Russell Bryant2012-07-181-1/+1
| | | | | | | | | | | | | | | | | | Change jsonutils.to_primitive() to increase the recursion depth counter when calling to_primitive() on the result of iteritems() from the current element. Previously, the only time the counter was increased was when converting the __dict__ from an object. The iteritems() case risks cycles, as well. I hit a problem with this when trying to call to_primitive on an instance of nova.db.sqlalchemy.models.Instance. An Instance includes a reference to InstanceInfoCache, which has a reference back to the Instance. Without this change, to_primitive() would raise an exception for an Instance due to excessive recursion. Related to nova blueprint no-db-messaging. Change-Id: Ifb878368d97e92ab6c361a4dd5f5ab2e68fc16e2
* Use strtime() in to_primitive() for datetime objs.Russell Bryant2012-07-161-1/+3
| | | | | | | | | | | This patch updates jsonutils.to_primitive() to use timeutils.strtime() to convert a datimetime object to a string instead of just using str(). This ensures that we can easily convert the string back to a datetime using timeutils.parse_strtime(). Required for the nova blueprint no-db-messaging. Change-Id: I725b333695930e12e2832378102514326fec639c
* Add 'filedecoder' method to the jsonutils wrapper module.Tim Daly Jr2012-06-261-1/+5
| | | | | | | | | | | Fixes bug #1017765 After version 3.3.2, the anyjson library will throw a KeyError if filedecoder isn't present. The filedecoder is just like the decoder except it takes a file instead of a string, like json.load() instead of json.loads(). Change-Id: I7bd012a7b4afa9b1ec987c3e6393cc922b5dadff
* Make jsonutils.dumps more generalZhongyue Luo2012-06-081-2/+2
| | | | | | | | Fixes bug #1009848 Fixed jsonutils.dumps to receive other parameters Change-Id: I34836ae89359bccb689a36a7b486e85bb41d70e4
* Handle xmlrpclib.DateTime types when serializing to JSONJohannes Erdfelt2012-06-071-0/+7
| | | | | | | | | Fixes bug 1010124 Convert xmlrpclib.DateTime types to datetime so they can be serialized without creating an exception. Change-Id: Ifcab69ad81d39d7f4066df5c71c6ab6734fb1fab
* Revert "Add a load function wrapper to jsonutils"Russell Bryant2012-06-061-8/+3
| | | | | | | | | | | This reverts commit 72840edc736b7f4d2366b5049f6516d8f5b901ff. This change breaks kombu, so revert it since there is no specific need for it. Fixes bug 1009127. Change-Id: Id0ef8b3948b63d0151289cb7ce8e617d9816bb4b
* Add a load function wrapper to jsonutilsZhongyue Luo2012-06-041-3/+8
| | | | | | Fixes bug #1008065 Change-Id: I72aba29eea4637643cb7742f2fd4b1f05d15667f
* Create openstack.common.jsonutils.Russell Bryant2012-05-151-0/+133
This patch creates a new module, jsonutils. It is based on some code from nova.utils that is used by nova.rpc. It is being added to openstack-common as another step toward being able to eventually move nova.rpc to openstack-common. This module provides a few things: 1) A handy function for getting an object down to something that can be JSON serialized. See to_primitive(). 2) Wrappers around loads() and dumps(). The dumps() wrapper will automatically use to_primitive() for you if needed. 3) This sets up anyjson to use the loads() and dumps() wrappers if anyjson is available. Change-Id: I41e5759360d515ed53defe69f3e8247aafbcc83a