Use the new encode_result functions of the rest encoding modules

This commit is contained in:
Christophe de Vienne 2012-11-29 00:13:51 +01:00
parent cda8563e5a
commit 33d852b2e4

View File

@ -1,10 +1,6 @@
import inspect
import sys
import json
import xml.etree.ElementTree as et
import wsme
import wsme.rest.args
import wsme.rest.json
@ -18,11 +14,10 @@ class JSonRenderer(object):
pass
def render(self, template_path, namespace):
data = wsme.rest.json.tojson(
return wsme.rest.json.encode_result(
namespace['datatype'],
namespace['result']
)
return json.dumps(data)
class XMLRenderer(object):
@ -30,12 +25,10 @@ class XMLRenderer(object):
pass
def render(self, template_path, namespace):
data = wsme.rest.xml.toxml(
return wsme.rest.xml.encode_result(
namespace['datatype'],
'result',
namespace['result']
)
return et.tostring(data)
pecan.templating._builtin_renderers['wsmejson'] = JSonRenderer
pecan.templating._builtin_renderers['wsmexml'] = XMLRenderer