Continue working on the rest-xml tests and implementation + changed the RestProtocol interface

This commit is contained in:
Christophe de Vienne
2011-09-20 20:11:42 +02:00
parent e96235f73a
commit e48d4311c0
3 changed files with 7 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ class RestProtocol(object):
try:
func, funcdef = root._lookup_function(path)
kw = self.get_args(request)
kw = self.decode_args(request, funcdef.arguments)
result = func(**kw)
# TODO make sure result type == a._wsme_definition.return_type
res.body = self.encode_result(result, funcdef.return_type)

View File

@@ -29,7 +29,7 @@ class RestJsonProtocol(RestProtocol):
dataformat = 'json'
content_types = ['application/json', 'text/json', None]
def get_args(self, req):
def decode_args(self, req, arguments):
kw = json.loads(req.body)
return kw

View File

@@ -15,11 +15,14 @@ class RestXmlProtocol(RestProtocol):
dataformat = 'xml'
content_types = ['text/xml']
def get_args(self, req):
kw = json.loads(req.body)
def decode_args(self, req, arguments):
el = et.fromstring(req.body)
assert el.tag == 'parameters'
kw = {}
return kw
def encode_result(self, result, return_type):
return '<result/>'
return json.dumps({'result': prepare_encode(result, return_type)})
def encode_error(self, errordetail):