diff options
-rw-r--r-- | module/obmc/wsgi/apps/rest_dbus.py | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index 540322b..e0c2edf 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -335,7 +335,8 @@ class MethodHandler(RouteHandler): m = self.find_method_on_bus(path, method, *items) if m: method_list.append(m) - return method_list + if method_list: + return method_list abort(404, _4034_msg % ('method', 'found', method)) @@ -344,12 +345,29 @@ class MethodHandler(RouteHandler): def do_post(self, path, method): try: - for item in request.route_data['map']: - if request.parameter_list: - item(*request.parameter_list) - else: - item() - return + args = [] + if request.parameter_list: + args = request.parameter_list + # To see if the return type is capable of being merged + if len(request.route_data['map']) > 1: + results = None + for item in request.route_data['map']: + tmp = item(*args) + if not results: + if tmp is not None: + results = type(tmp)() + if isinstance(results, dict): + results = results.update(tmp) + elif isinstance(results, list): + results = results + tmp + elif isinstance(results, type(None)): + results = None + else: + abort(501, 'Don\'t know how to merge method call ' + 'results of {}'.format(type(tmp))) + return results + # There is only one method + return request.route_data['map'][0](*args) except dbus.exceptions.DBusException, e: paramlist = [] |