diff --git a/modules/plugin_dbui/directsvc.py b/modules/plugin_dbui/directsvc.py index 1fdff7dafb660083cd2bbaf79c8b49c06f35d4bf..ed64136b6c1aa5c0e98d0f55f0ad8cd7df7b78a0 100644 --- a/modules/plugin_dbui/directsvc.py +++ b/modules/plugin_dbui/directsvc.py @@ -6,6 +6,7 @@ __version__ = "$Revision$" import pprint +import traceback import sys from gluon.contrib import simplejson as json @@ -74,7 +75,7 @@ class DirectSvc(object): if len(request.args) == 1 and request.args(0) == 'get_api': return self.get_api() - self.error() + self.error(404, 'Object does not exist.') def dbg(self, *args): @@ -92,8 +93,8 @@ class DirectSvc(object): return x - def error(self): - raise HTTP(404, 'Object does not exist.') + def error(self, code, message): + raise HTTP(code, message) def get_api(self): @@ -165,13 +166,17 @@ class DirectSvc(object): li = [] for arg in transactions: di = dict(arg) + self.dbg('transaction:', di) try: k = proc_key(arg['action'], arg['method']) - di['result'] = self.procedures[k](*arg['data']) + if arg['data']: + di['result'] = self.procedures[k](*arg['data']) + else: + di['result'] = self.procedures[k]() - except Exception: + except Exception, e: traceback.print_exc(file=sys.stdout) - raise HTTP(500, 'Error on the server') + self.error(500, 'Internal server error.') del di['data'] li.append(di)