Continue working on the rest-xml tests and implementation + changed the RestProtocol interface
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user