Use OSLO jsonutils instead of json module

For most things there is very little difference, but as we have a
jsonutils module we should probably be using it.

Change-Id: I406ea81bb56ad90cc9ff9b8b58b0d35b694dc802
This commit is contained in:
Jamie Lennox
2013-08-16 11:45:44 +10:00
parent 7eb6f80517
commit 6da9262b03
3 changed files with 9 additions and 14 deletions

View File

@@ -21,11 +21,6 @@ except ImportError:
keyring = None
pickle = None
try:
import json
except ImportError:
import simplejson as json
# Python 2.5 compat fix
if not hasattr(urlparse, 'parse_qsl'):
import cgi
@@ -34,6 +29,7 @@ if not hasattr(urlparse, 'parse_qsl'):
from keystoneclient import access
from keystoneclient import exceptions
from keystoneclient.openstack.common import jsonutils
_logger = logging.getLogger(__name__)
@@ -574,7 +570,7 @@ class HTTPClient(object):
raise NotImplementedError
def serialize(self, entity):
return json.dumps(entity)
return jsonutils.dumps(entity)
@property
def service_catalog(self):
@@ -610,7 +606,7 @@ class HTTPClient(object):
if resp.text:
try:
body_resp = json.loads(resp.text)
body_resp = jsonutils.loads(resp.text)
except (ValueError, TypeError):
body_resp = None
_logger.debug("Could not decode JSON from body: %s"

View File

@@ -146,7 +146,6 @@ keystone.token_info
import datetime
import httplib
import json
import logging
import os
import stat
@@ -781,7 +780,7 @@ class AuthProtocol(object):
return cached
if cms.is_ans1_token(user_token):
verified = self.verify_signed_token(user_token)
data = json.loads(verified)
data = jsonutils.loads(verified)
else:
data = self.verify_uuid_token(user_token, retry)
expires = self._confirm_token_not_expired(data)
@@ -970,8 +969,8 @@ class AuthProtocol(object):
# Note that 'invalid' and (data, expires) are the only
# valid types of serialized cache entries, so there is not
# a collision with json.loads(serialized) == None.
cached = json.loads(serialized)
# a collision with jsonutils.loads(serialized) == None.
cached = jsonutils.loads(serialized)
if cached == 'invalid':
self.LOG.debug('Cached Token %s is marked unauthorized', token)
raise InvalidUserToken('Token authorization failed')
@@ -989,7 +988,7 @@ class AuthProtocol(object):
data may be the string 'invalid' or a tuple like (data, expires)
"""
serialized_data = json.dumps(data)
serialized_data = jsonutils.dumps(data)
if self._memcache_security_strategy is None:
cache_key = CACHE_KEY_TEMPLATE % token
data_to_store = serialized_data

View File

@@ -12,11 +12,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
import logging
from keystoneclient import exceptions
from keystoneclient import httpclient
from keystoneclient.openstack.common import jsonutils
from keystoneclient.v3.contrib import trusts
from keystoneclient.v3 import credentials
from keystoneclient.v3 import domains
@@ -104,7 +104,7 @@ class Client(httpclient.HTTPClient):
self.authenticate()
def serialize(self, entity):
return json.dumps(entity, sort_keys=True)
return jsonutils.dumps(entity, sort_keys=True)
def process_token(self):
"""Extract and process information from the new auth_ref.