diff --git a/wsme/rest/args.py b/wsme/rest/args.py
index 2a49672..9dc16c7 100644
--- a/wsme/rest/args.py
+++ b/wsme/rest/args.py
@@ -216,8 +216,8 @@ def args_from_params(funcdef, params):
def args_from_body(funcdef, body, mimetype):
- from wsme.rest import json_utils as restjson
- from wsme.rest import xml_utils as restxml
+ from wsme.rest import json as restjson
+ from wsme.rest import xml as restxml
if funcdef.body_type is not None:
datatypes = {funcdef.arguments[-1].name: funcdef.body_type}
diff --git a/wsme/rest/json_utils.py b/wsme/rest/json.py
similarity index 99%
rename from wsme/rest/json_utils.py
rename to wsme/rest/json.py
index a7c2f4f..cf8727c 100644
--- a/wsme/rest/json_utils.py
+++ b/wsme/rest/json.py
@@ -1,4 +1,6 @@
"""REST+Json protocol implementation."""
+from __future__ import absolute_import
+
import datetime
import decimal
import json
diff --git a/wsme/rest/protocol.py b/wsme/rest/protocol.py
index f5a0625..1ecf4de 100644
--- a/wsme/rest/protocol.py
+++ b/wsme/rest/protocol.py
@@ -25,8 +25,8 @@ class RestProtocol(Protocol):
self.content_types = []
for dataformat in dataformats:
- __import__('wsme.rest.' + dataformat + '_utils')
- dfmod = getattr(wsme.rest, dataformat + '_utils')
+ __import__('wsme.rest.' + dataformat)
+ dfmod = getattr(wsme.rest, dataformat)
self.dataformats[dataformat] = dfmod
self.content_types.extend(dfmod.accept_content_types)
diff --git a/wsme/rest/xml_utils.py b/wsme/rest/xml.py
similarity index 100%
rename from wsme/rest/xml_utils.py
rename to wsme/rest/xml.py
diff --git a/wsme/tests/test_restjson.py b/wsme/tests/test_restjson.py
index eca8e47..9935f98 100644
--- a/wsme/tests/test_restjson.py
+++ b/wsme/tests/test_restjson.py
@@ -7,7 +7,7 @@ from wsme.exc import ClientSideError, InvalidInput
from wsme.types import isarray, isdict, isusertype, register_type
from wsme.types import UserType, ArrayType, DictType
from wsme.rest import expose, validate
-from wsme.rest.json_utils import fromjson, tojson, parse
+from wsme.rest.json import fromjson, tojson, parse
import wsme.tests.protocol
from wsme.utils import parse_isodatetime, parse_isotime, parse_isodate
@@ -563,7 +563,7 @@ class TestRestJson(wsme.tests.protocol.RestOnlyProtocolTestCase):
v.aint = 4
v.astr = 's'
- r = wsme.rest.json_utils.encode_sample_value(MyType, v, True)
+ r = wsme.rest.json.encode_sample_value(MyType, v, True)
print(r)
assert r[0] == ('javascript')
assert r[1] == json.dumps({'aint': 4, 'astr': 's'}, ensure_ascii=False,
@@ -574,7 +574,7 @@ class TestRestJson(wsme.tests.protocol.RestOnlyProtocolTestCase):
assert tojson(wsme.types.bytes, b('ascii')) == u('ascii')
def test_encode_sample_params(self):
- r = wsme.rest.json_utils.encode_sample_params(
+ r = wsme.rest.json.encode_sample_params(
[('a', int, 2)], True
)
assert r[0] == 'javascript', r[0]
@@ -583,7 +583,7 @@ class TestRestJson(wsme.tests.protocol.RestOnlyProtocolTestCase):
}''', r[1]
def test_encode_sample_result(self):
- r = wsme.rest.json_utils.encode_sample_result(
+ r = wsme.rest.json.encode_sample_result(
int, 2, True
)
assert r[0] == 'javascript', r[0]
diff --git a/wsme/tests/test_restxml.py b/wsme/tests/test_restxml.py
index 3fc01fe..9e2f08d 100644
--- a/wsme/tests/test_restxml.py
+++ b/wsme/tests/test_restxml.py
@@ -5,7 +5,7 @@ import base64
from six import u, b
import six
-from wsme.rest.xml_utils import fromxml, toxml
+from wsme.rest.xml import fromxml, toxml
import wsme.tests.protocol
from wsme.types import isarray, isdict, isusertype, register_type
from wsme.utils import parse_isodatetime, parse_isodate, parse_isotime
@@ -164,7 +164,7 @@ class TestRestXML(wsme.tests.protocol.RestOnlyProtocolTestCase):
value.aint = 5
value.atext = u('test')
- language, sample = wsme.rest.xml_utils.encode_sample_value(
+ language, sample = wsme.rest.xml.encode_sample_value(
MyType, value, True)
print(language, sample)
@@ -175,13 +175,13 @@ class TestRestXML(wsme.tests.protocol.RestOnlyProtocolTestCase):
""")
def test_encode_sample_params(self):
- lang, content = wsme.rest.xml_utils.encode_sample_params(
+ lang, content = wsme.rest.xml.encode_sample_params(
[('a', int, 2)], True)
assert lang == 'xml', lang
assert content == b('\n 2\n'), content
def test_encode_sample_result(self):
- lang, content = wsme.rest.xml_utils.encode_sample_result(int, 2, True)
+ lang, content = wsme.rest.xml.encode_sample_result(int, 2, True)
assert lang == 'xml', lang
assert content == b('2'), content
diff --git a/wsmeext/flask.py b/wsmeext/flask.py
index d6e57ab..86df242 100644
--- a/wsmeext/flask.py
+++ b/wsmeext/flask.py
@@ -10,17 +10,17 @@ import flask
import wsme
import wsme.api
import wsme.rest.args
-import wsme.rest.json_utils
-import wsme.rest.xml_utils
+import wsme.rest.json
+import wsme.rest.xml
from wsme.utils import is_valid_code
log = logging.getLogger(__name__)
TYPES = {
- 'application/json': wsme.rest.json_utils,
- 'application/xml': wsme.rest.xml_utils,
- 'text/xml': wsme.rest.xml_utils,
+ 'application/json': wsme.rest.json,
+ 'application/xml': wsme.rest.xml,
+ 'text/xml': wsme.rest.xml,
}
@@ -37,7 +37,7 @@ def get_dataformat():
log.info('Could not determine what format is wanted by the caller, '
'falling back to JSON')
- return wsme.rest.json_utils
+ return wsme.rest.json
def signature(*args, **kw):
diff --git a/wsmeext/pecan.py b/wsmeext/pecan.py
index 474c45e..54a1a73 100644
--- a/wsmeext/pecan.py
+++ b/wsmeext/pecan.py
@@ -8,8 +8,8 @@ import pecan
import wsme
import wsme.rest.args
-import wsme.rest.json_utils
-import wsme.rest.xml_utils
+import wsme.rest.json
+import wsme.rest.xml
from wsme.utils import is_valid_code
@@ -21,8 +21,8 @@ class JSonRenderer(object):
@staticmethod
def render(template_path, namespace):
if 'faultcode' in namespace:
- return wsme.rest.json_utils.encode_error(None, namespace)
- return wsme.rest.json_utils.encode_result(
+ return wsme.rest.json.encode_error(None, namespace)
+ return wsme.rest.json.encode_result(
namespace['result'],
namespace['datatype']
)
@@ -36,8 +36,8 @@ class XMLRenderer(object):
@staticmethod
def render(template_path, namespace):
if 'faultcode' in namespace:
- return wsme.rest.xml_utils.encode_error(None, namespace)
- return wsme.rest.xml_utils.encode_result(
+ return wsme.rest.xml.encode_error(None, namespace)
+ return wsme.rest.xml.encode_result(
namespace['result'],
namespace['datatype']
)
diff --git a/wsmeext/sphinxext.py b/wsmeext/sphinxext.py
index 4ca5370..7e40cfa 100644
--- a/wsmeext/sphinxext.py
+++ b/wsmeext/sphinxext.py
@@ -16,8 +16,8 @@ from sphinx.util.docfields import Field
from sphinx.util.nodes import make_refnode
import wsme
-import wsme.rest.json_utils
-import wsme.rest.xml_utils
+import wsme.rest.json
+import wsme.rest.xml
import wsme.types
field_re = re.compile(r':(?P\w+)(\s+(?P\w+))?:')
@@ -53,10 +53,10 @@ def get_protocols(names):
protocols.extend('restjson', 'restxml')
if 'restjson' in names:
names.remove('restjson')
- protocols.append(('Json', wsme.rest.json_utils))
+ protocols.append(('Json', wsme.rest.json))
if 'restxml' in names:
names.remove('restxml')
- protocols.append(('XML', wsme.rest.xml_utils))
+ protocols.append(('XML', wsme.rest.xml))
for name in names:
p = wsme.protocol.getprotocol(name)
protocols.append((p.displayname or p.name, p))