Cornice extension: Fix function args preparation, and choose the renderer based on the 'Accept' header
This commit is contained in:
parent
0b2cf8df04
commit
e4b852292f
@ -68,10 +68,14 @@ def wsexpose(*args, **kwargs):
|
||||
@functools.wraps(f)
|
||||
def callfunction(request):
|
||||
args, kwargs = combine_args(
|
||||
funcdef,
|
||||
args_from_params(funcdef, request.params),
|
||||
args_from_body(funcdef, request.body, request.content_type)
|
||||
)
|
||||
request.override_renderer = 'wsmexml'
|
||||
if 'application/json' in request.headers['Accept']:
|
||||
request.override_renderer = 'wsmejson'
|
||||
elif 'text/xml' in request.headers['Accept']:
|
||||
request.override_renderer = 'wsmexml'
|
||||
return {
|
||||
'datatype': funcdef.return_type,
|
||||
'result': f(*args, **kwargs)
|
||||
|
@ -137,7 +137,7 @@ def args_from_params(funcdef, params):
|
||||
unknown_paths = paths - hit_paths
|
||||
if unknown_paths:
|
||||
raise UnknownArgument(', '.join(unknown_paths))
|
||||
return kw
|
||||
return [], kw
|
||||
|
||||
|
||||
def args_from_body(funcdef, body, mimetype):
|
||||
|
Loading…
x
Reference in New Issue
Block a user