# TODO modules that import netsvc only for things from loglevels must be changed to use loglevels.
from loglevels import *
import tools
-import openerp.exceptions
def close_socket(sock):
""" Closes a socket instance cleanly
#.apidoc title: Common Services: netsvc
#.apidoc module-mods: member-order: bysource
-def abort_response(dummy_1, description, dummy_2, details):
- # TODO Replace except_{osv,orm} with these directly.
- if description == 'AccessError':
- raise openerp.exceptions.AccessError(details)
+def abort_response(error, description, origin, details):
+ if not tools.config['debug_mode']:
+ raise Exception("%s -- %s\n\n%s"%(origin, description, details))
else:
- raise openerp.exceptions.Warning(details)
+ raise
class Service(object):
""" Base class for *Local* services
class ExportService(object):
""" Proxy for exported services.
+ All methods here should take an AuthProxy as their first parameter. It
+ will be appended by the calling framework.
+
Note that this class has no direct proxy, capable of calling
eservice.method(). Rather, the proxy should call
- dispatch(method, params)
+ dispatch(method,auth,params)
"""
_services = {}
# Dispatch a RPC call w.r.t. the method name. The dispatching
# w.r.t. the service (this class) is done by OpenERPDispatcher.
- def dispatch(self, method, params):
+ def dispatch(self, method, auth, params):
raise Exception("stub dispatch at %s" % self.__name)
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, _NOTHING, DEFAULT = range(10)
logger.log(channel, indent+line)
indent=indent_after
-def dispatch_rpc(service_name, method, params):
+def dispatch_rpc(service_name, method, params, auth):
""" Handle a RPC call.
This is pure Python code, the actual marshalling (from/to XML-RPC or
_log('service', tuple(replace_request_password(params)), depth=None, fn='%s.%s'%(service_name,method))
if logger.isEnabledFor(logging.DEBUG_RPC):
start_time = time.time()
- result = ExportService.getService(service_name).dispatch(method, params)
+ result = ExportService.getService(service_name).dispatch(method, auth, params)
if logger.isEnabledFor(logging.DEBUG_RPC):
end_time = time.time()
if not logger.isEnabledFor(logging.DEBUG_RPC_ANSWER):
_log('execution time', '%.3fs' % (end_time - start_time), channel=logging.DEBUG_RPC_ANSWER)
_log('result', result, channel=logging.DEBUG_RPC_ANSWER)
return result
- except openerp.exceptions.AccessError:
- raise
- except openerp.exceptions.AccessDenied:
- raise
- except openerp.exceptions.Warning:
- raise
except Exception, e:
_log('exception', tools.exception_to_unicode(e))
tb = getattr(e, 'traceback', sys.exc_info())