-
-def close_socket(sock):
- """ Closes a socket instance cleanly
-
- :param sock: the network socket to close
- :type sock: socket.socket
- """
- try:
- sock.shutdown(socket.SHUT_RDWR)
- except socket.error, e:
- # On OSX, socket shutdowns both sides if any side closes it
- # causing an error 57 'Socket is not connected' on shutdown
- # of the other side (or something), see
- # http://bugs.python.org/issue4397
- # note: stdlib fixed test, not behavior
- if e.errno != errno.ENOTCONN or platform.system() not in ['Darwin', 'Windows']:
- raise
- sock.close()
-
-def abort_response(dummy_1, description, dummy_2, details):
- # TODO Replace except_{osv,orm} with these directly.
- raise openerp.osv.osv.except_osv(description, details)
-
-class Service(object):
- """ Base class for Local services
- Functionality here is trusted, no authentication.
- Workflow engine and reports subclass this.
- """
- _services = {}
- def __init__(self, name):
- Service._services[name] = self
- self.__name = name
-
- @classmethod
- def exists(cls, name):
- return name in cls._services
-
- @classmethod
- def remove(cls, name):
- if cls.exists(name):
- cls._services.pop(name)
-