metadef modules should only use - from wsme.rest import json
Several metadef module routines use: from wsme.rest.json import fromjson from wsme.rest.json import tojson To follow the import rules at http://docs.openstack.org/developer/hacking/ (only import modules), these should be replaced with: from wsme.rest import json Change-Id: Idc496c8753d93a3d39f0c9cbbb31205948eeb081 Closes-bug: 1392485
This commit is contained in:
parent
b289e40c22
commit
d25fa06db6
|
@ -14,12 +14,11 @@
|
|||
# limitations under the License.
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils as json
|
||||
from oslo.serialization import jsonutils
|
||||
import six
|
||||
import six.moves.urllib.parse as urlparse
|
||||
import webob.exc
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest.json import tojson
|
||||
from wsme.rest import json
|
||||
|
||||
from glance.api import policy
|
||||
from glance.api.v2.model.metadef_namespace import Namespace
|
||||
|
@ -172,7 +171,7 @@ class NamespaceController(object):
|
|||
def _to_property_dict(self, name, value):
|
||||
# Convert the model PropertyTypes dict to a JSON string
|
||||
db_property_type_dict = dict()
|
||||
db_property_type_dict['schema'] = tojson(PropertyType, value)
|
||||
db_property_type_dict['schema'] = json.tojson(PropertyType, value)
|
||||
db_property_type_dict['name'] = name
|
||||
return db_property_type_dict
|
||||
|
||||
|
@ -430,7 +429,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
namespace = fromjson(Namespace, body)
|
||||
namespace = json.fromjson(Namespace, body)
|
||||
return dict(namespace=namespace)
|
||||
|
||||
def update(self, request):
|
||||
|
@ -440,7 +439,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
namespace = fromjson(Namespace, body)
|
||||
namespace = json.fromjson(Namespace, body)
|
||||
return dict(user_ns=namespace)
|
||||
|
||||
|
||||
|
@ -450,12 +449,12 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
self.schema = schema
|
||||
|
||||
def create(self, response, namespace):
|
||||
ns_json = tojson(Namespace, namespace)
|
||||
ns_json = json.tojson(Namespace, namespace)
|
||||
response = self.__render(ns_json, response, 201)
|
||||
response.location = get_namespace_href(namespace)
|
||||
|
||||
def show(self, response, namespace):
|
||||
ns_json = tojson(Namespace, namespace)
|
||||
ns_json = json.tojson(Namespace, namespace)
|
||||
response = self.__render(ns_json, response)
|
||||
|
||||
def index(self, response, result):
|
||||
|
@ -471,11 +470,11 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
next_query = urlparse.urlencode(params)
|
||||
result.next = '/v2/metadefs/namespaces?%s' % next_query
|
||||
|
||||
ns_json = tojson(Namespaces, result)
|
||||
ns_json = json.tojson(Namespaces, result)
|
||||
response = self.__render(ns_json, response)
|
||||
|
||||
def update(self, response, namespace):
|
||||
ns_json = tojson(Namespace, namespace)
|
||||
ns_json = json.tojson(Namespace, namespace)
|
||||
response = self.__render(ns_json, response, 200)
|
||||
|
||||
def delete(self, response, result):
|
||||
|
@ -488,7 +487,7 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
response.status_int = 204
|
||||
|
||||
def __render(self, json_data, response, response_status=None):
|
||||
body = json.dumps(json_data, ensure_ascii=False)
|
||||
body = jsonutils.dumps(json_data, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
if response_status:
|
||||
|
|
|
@ -14,11 +14,10 @@
|
|||
# limitations under the License.
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.serialization import jsonutils as json
|
||||
from oslo.serialization import jsonutils
|
||||
import six
|
||||
import webob.exc
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest.json import tojson
|
||||
from wsme.rest import json
|
||||
|
||||
from glance.api import policy
|
||||
from glance.api.v2 import metadef_namespaces as namespaces
|
||||
|
@ -233,7 +232,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
metadata_object = fromjson(MetadefObject, body)
|
||||
metadata_object = json.fromjson(MetadefObject, body)
|
||||
return dict(metadata_object=metadata_object)
|
||||
|
||||
def update(self, request):
|
||||
|
@ -243,7 +242,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
metadata_object = fromjson(MetadefObject, body)
|
||||
metadata_object = json.fromjson(MetadefObject, body)
|
||||
return dict(metadata_object=metadata_object)
|
||||
|
||||
def index(self, request):
|
||||
|
@ -300,8 +299,8 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
self.show(response, metadata_object)
|
||||
|
||||
def show(self, response, metadata_object):
|
||||
metadata_object_json = tojson(MetadefObject, metadata_object)
|
||||
body = json.dumps(metadata_object_json, ensure_ascii=False)
|
||||
metadata_object_json = json.tojson(MetadefObject, metadata_object)
|
||||
body = jsonutils.dumps(metadata_object_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
|
@ -311,8 +310,8 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
|
||||
def index(self, response, result):
|
||||
result.schema = "v2/schemas/metadefs/objects"
|
||||
metadata_objects_json = tojson(MetadefObjects, result)
|
||||
body = json.dumps(metadata_objects_json, ensure_ascii=False)
|
||||
metadata_objects_json = json.tojson(MetadefObjects, result)
|
||||
body = jsonutils.dumps(metadata_objects_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo.serialization import jsonutils as json
|
||||
from oslo.serialization import jsonutils
|
||||
import six
|
||||
import webob.exc
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest.json import tojson
|
||||
from wsme.rest import json
|
||||
|
||||
from glance.api import policy
|
||||
from glance.api.v2 import metadef_namespaces as namespaces
|
||||
|
@ -49,14 +48,14 @@ class NamespacePropertiesController(object):
|
|||
def _to_dict(self, model_property_type):
|
||||
# Convert the model PropertyTypes dict to a JSON encoding
|
||||
db_property_type_dict = dict()
|
||||
db_property_type_dict['schema'] = tojson(
|
||||
db_property_type_dict['schema'] = json.tojson(
|
||||
PropertyType, model_property_type)
|
||||
db_property_type_dict['name'] = model_property_type.name
|
||||
return db_property_type_dict
|
||||
|
||||
def _to_model(self, db_property_type):
|
||||
# Convert the persisted json schema to a dict of PropertyTypes
|
||||
property_type = fromjson(
|
||||
property_type = json.fromjson(
|
||||
PropertyType, db_property_type.schema)
|
||||
property_type.name = db_property_type.name
|
||||
return property_type
|
||||
|
@ -188,7 +187,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
property_type = fromjson(PropertyType, body)
|
||||
property_type = json.fromjson(PropertyType, body)
|
||||
return dict(property_type=property_type)
|
||||
|
||||
def update(self, request):
|
||||
|
@ -198,7 +197,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
property_type = fromjson(PropertyType, body)
|
||||
property_type = json.fromjson(PropertyType, body)
|
||||
return dict(property_type=property_type)
|
||||
|
||||
def show(self, request):
|
||||
|
@ -215,14 +214,14 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
self.schema = schema
|
||||
|
||||
def show(self, response, result):
|
||||
property_type_json = tojson(PropertyType, result)
|
||||
body = json.dumps(property_type_json, ensure_ascii=False)
|
||||
property_type_json = json.tojson(PropertyType, result)
|
||||
body = jsonutils.dumps(property_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
def index(self, response, result):
|
||||
property_type_json = tojson(PropertyTypes, result)
|
||||
body = json.dumps(property_type_json, ensure_ascii=False)
|
||||
property_type_json = json.tojson(PropertyTypes, result)
|
||||
body = jsonutils.dumps(property_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo.serialization import jsonutils as json
|
||||
from oslo.serialization import jsonutils
|
||||
import six
|
||||
import webob.exc
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest.json import tojson
|
||||
from wsme.rest import json
|
||||
|
||||
from glance.api import policy
|
||||
from glance.api.v2.model.metadef_resource_type import ResourceType
|
||||
|
@ -160,7 +159,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
resource_type = fromjson(ResourceTypeAssociation, body)
|
||||
resource_type = json.fromjson(ResourceTypeAssociation, body)
|
||||
return dict(resource_type=resource_type)
|
||||
|
||||
|
||||
|
@ -170,21 +169,21 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
self.schema = schema
|
||||
|
||||
def show(self, response, result):
|
||||
resource_type_json = tojson(ResourceTypeAssociations, result)
|
||||
body = json.dumps(resource_type_json, ensure_ascii=False)
|
||||
resource_type_json = json.tojson(ResourceTypeAssociations, result)
|
||||
body = jsonutils.dumps(resource_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
def index(self, response, result):
|
||||
resource_type_json = tojson(ResourceTypes, result)
|
||||
body = json.dumps(resource_type_json, ensure_ascii=False)
|
||||
resource_type_json = json.tojson(ResourceTypes, result)
|
||||
body = jsonutils.dumps(resource_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
def create(self, response, result):
|
||||
resource_type_json = tojson(ResourceTypeAssociation, result)
|
||||
resource_type_json = json.tojson(ResourceTypeAssociation, result)
|
||||
response.status_int = 201
|
||||
body = json.dumps(resource_type_json, ensure_ascii=False)
|
||||
body = jsonutils.dumps(resource_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
import wsme
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest import json
|
||||
from wsme import types
|
||||
|
||||
from glance.api.v2.model.metadef_object import MetadefObject
|
||||
|
@ -56,7 +56,7 @@ class Namespace(types.Base, WSMEModelTransformer):
|
|||
property_types = {}
|
||||
for db_property_type in db_property_types:
|
||||
# Convert the persisted json schema to a dict of PropertyTypes
|
||||
property_type = fromjson(
|
||||
property_type = json.fromjson(
|
||||
PropertyType, db_property_type.schema)
|
||||
property_type_name = db_property_type.name
|
||||
property_types[property_type_name] = property_type
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import importutils
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest.json import tojson
|
||||
from wsme.rest import json
|
||||
|
||||
from glance.api.v2.model.metadef_property_type import PropertyType
|
||||
from glance.common import crypt
|
||||
|
@ -509,7 +508,7 @@ class MetadefObjectRepo(object):
|
|||
property_types = {}
|
||||
json_props = metadata_object['json_schema']
|
||||
for id in json_props:
|
||||
property_types[id] = fromjson(PropertyType, json_props[id])
|
||||
property_types[id] = json.fromjson(PropertyType, json_props[id])
|
||||
|
||||
return glance.domain.MetadefObject(
|
||||
namespace=namespace_entity,
|
||||
|
@ -532,7 +531,7 @@ class MetadefObjectRepo(object):
|
|||
db_schema = {}
|
||||
if properties:
|
||||
for k, v in properties.items():
|
||||
json_data = tojson(PropertyType, v)
|
||||
json_data = json.tojson(PropertyType, v)
|
||||
db_schema[k] = json_data
|
||||
|
||||
db_metadata_object = {
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo.serialization import jsonutils as json
|
||||
from oslo.serialization import jsonutils
|
||||
import six
|
||||
import webob.exc
|
||||
from wsme.rest.json import fromjson
|
||||
from wsme.rest.json import tojson
|
||||
from wsme.rest import json
|
||||
|
||||
from glance.api import policy
|
||||
from glance.api.v2.model.metadef_resource_type import ResourceType
|
||||
|
@ -164,7 +163,7 @@ class RequestDeserializer(wsgi.JSONRequestDeserializer):
|
|||
self.schema.validate(body)
|
||||
except exception.InvalidObject as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=e.msg)
|
||||
resource_type = fromjson(ResourceTypeAssociation, body)
|
||||
resource_type = json.fromjson(ResourceTypeAssociation, body)
|
||||
return dict(resource_type=resource_type)
|
||||
|
||||
|
||||
|
@ -174,21 +173,21 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
|||
self.schema = schema
|
||||
|
||||
def show(self, response, result):
|
||||
resource_type_json = tojson(ResourceTypeAssociations, result)
|
||||
body = json.dumps(resource_type_json, ensure_ascii=False)
|
||||
resource_type_json = json.tojson(ResourceTypeAssociations, result)
|
||||
body = jsonutils.dumps(resource_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
def index(self, response, result):
|
||||
resource_type_json = tojson(ResourceTypes, result)
|
||||
body = json.dumps(resource_type_json, ensure_ascii=False)
|
||||
resource_type_json = json.tojson(ResourceTypes, result)
|
||||
body = jsonutils.dumps(resource_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
def create(self, response, result):
|
||||
resource_type_json = tojson(ResourceTypeAssociation, result)
|
||||
resource_type_json = json.tojson(ResourceTypeAssociation, result)
|
||||
response.status_int = 201
|
||||
body = json.dumps(resource_type_json, ensure_ascii=False)
|
||||
body = jsonutils.dumps(resource_type_json, ensure_ascii=False)
|
||||
response.unicode_body = six.text_type(body)
|
||||
response.content_type = 'application/json'
|
||||
|
||||
|
|
Loading…
Reference in New Issue