Beispiel #1
0
    def execute(self, path):
        #print "PATH: ", path
        path = path.strip('/')
        path = path.split('?')
        model = path[0]
        arguments = {}
        for argument in path[-1].split('&'):
            argument = argument.split('=')
            arguments[ argument[0] ] = argument[-1]

        use_cache = tools.config.get('jasper_cache', True)
        database = arguments.get('database', tools.config.get('jasper_database', 'stable8') )
        user = arguments.get('user', tools.config.get('jasper_user', 'admin') )
        password = arguments.get('password', tools.config.get('jasper_password', 'a') )
        depth = int( arguments.get('depth', tools.config.get('jasper_depth', 3) ) )
        language = arguments.get('language', tools.config.get('jasper_language', 'en'))
        # Check if data is in cache already
        key = '%s|%s|%s|%s|%s' % (model, database, user, depth, language)
        if key in self.cache:
            return self.cache[key]

        context = {
            'lang': language,
        }

        uid = netsvc.dispatch_rpc('common', 'login', (database, user, password))
        result = netsvc.dispatch_rpc('object', 'execute', (database, uid, password, 'ir.actions.report.xml', 'create_xml', model, depth, context))

        if use_cache:
            self.cache[key] = result

        return result
Beispiel #2
0
    def execute(self, path):
        #print "PATH: ", path
        path = path.strip('/')
        path = path.split('?')
        model = path[0]
        arguments = {}
        for argument in path[-1].split('&'):
            argument = argument.split('=')
            arguments[ argument[0] ] = argument[-1]

        use_cache = tools.config.get('jasper_cache', True)
        database = arguments.get('database', tools.config.get('jasper_database', 'demo') )
        user = arguments.get('user', tools.config.get('jasper_user', 'admin') )
        password = arguments.get('password', tools.config.get('jasper_password', 'admin') )
        depth = int( arguments.get('depth', tools.config.get('jasper_depth', 3) ) )
        language = arguments.get('language', tools.config.get('jasper_language', 'en'))

        # Check if data is in cache already
        key = '%s|%s|%s|%s|%s' % (model, database, user, depth, language)
        if key in self.cache:
            return self.cache[key]

        context = {
            'lang': language,
        }

        uid = netsvc.dispatch_rpc('common', 'login', (database, user, password))
        result = netsvc.dispatch_rpc('object', 'execute', (database, uid, password, 'ir.actions.report.xml', 'create_xml', model, depth, context))

        if use_cache:
            self.cache[key] = result

        return result
Beispiel #3
0
    def run(self):
        self.running = True
        try:
            ts = tiny_socket.mysocket(self.sock)
        except Exception:
            self.threads.remove(self)
            self.running = False
            return False

        while self.running:
            try:
                msg = ts.myreceive()
                result = netsvc.dispatch_rpc(msg[0], msg[1], msg[2:])
                ts.mysend(result)
            except socket.timeout:
                #terminate this channel because other endpoint is gone
                break
            except Exception, e:
                try:
                    valid_exception = Exception(
                        netrpc_handle_exception_legacy(e))
                    valid_traceback = getattr(e, 'traceback', sys.exc_info())
                    formatted_traceback = "".join(
                        traceback.format_exception(*valid_traceback))
                    _logger.debug("netrpc: communication-level exception",
                                  exc_info=True)
                    ts.mysend(valid_exception,
                              exception=True,
                              traceback=formatted_traceback)
                    break
                except Exception, ex:
                    #terminate this channel if we can't properly send back the error
                    _logger.exception(
                        "netrpc: cannot deliver exception message to client")
                    break
    def run(self):
        self.running = True
        try:
            ts = tiny_socket.mysocket(self.sock)
        except Exception:
            self.threads.remove(self)
            self.running = False
            return False

        while self.running:
            try:
                msg = ts.myreceive()
                result = netsvc.dispatch_rpc(msg[0], msg[1], msg[2:])
                ts.mysend(result)
            except socket.timeout:
                #terminate this channel because other endpoint is gone
                break
            except Exception, e:
                try:
                    valid_exception = Exception(netrpc_handle_exception_legacy(e)) 
                    valid_traceback = getattr(e, 'traceback', sys.exc_info())
                    formatted_traceback = "".join(traceback.format_exception(*valid_traceback))
                    _logger.debug("netrpc: communication-level exception", exc_info=True)
                    ts.mysend(valid_exception, exception=True, traceback=formatted_traceback)
                    break
                except Exception, ex:
                    #terminate this channel if we can't properly send back the error
                    _logger.exception("netrpc: cannot deliver exception message to client")
                    break