def generate_html_documentation(self):
        methods = {}
        for method_name in self.system_listMethods():
            if method_name in self.funcs:
                method = self.funcs[method_name]
            elif self.instance is not None:
                method_info = [None, None]
                if hasattr(self.instance, '_get_method_argstring'):
                    method_info[0] = self.instance._get_method_argstring(
                        method_name)
                if hasattr(self.instance, '_methodHelp'):
                    method_info[1] = self.instance._methodHelp(method_name)
                method_info = tuple(method_info)
                if method_info != (None, None):
                    method = method_info
                elif not hasattr(self.instance, '_dispatch'):
                    try:
                        method = resolve_dotted_attribute(
                            self.instance, method_name)
                    except AttributeError:
                        method = method_info

                else:
                    method = method_info
            methods[method_name] = method

        documenter = ServerHTMLDoc()
        documentation = documenter.docserver(self.server_name,
                                             self.server_documentation,
                                             methods)
        return documenter.page(self.server_title, documentation)
Exemple #2
0
    def _dispatch(self, method, params):
        """
        Method based on SimpleXMLRPCDispatcher to pass the request object
        as argument.
        """
        func = None
        try:
            # check to see if a matching function has been registered
            func = self.server.funcs[method]
        except KeyError:
            if self.server.instance is not None:
                # check for a _dispatch method
                if hasattr(self.server.instance, '_dispatch'):
                    return self.server.instance._dispatch(method, params)
                else:
                    # call instance method directly
                    try:
                        func = resolve_dotted_attribute(
                            self.server.instance, method,
                            self.server.allow_dotted_names)
                    except AttributeError:
                        pass

        request = Request(
            client_address=self.client_address,
            headers=self.headers,
        )
        if func is not None:
            return func(request, *params)
        else:
            raise Exception('method "%s" is not supported' % method)
Exemple #3
0
    def _dispatch(self, request, method, params):
        func = None
        try:
            # check to see if a matching function has been registered
            func = self.funcs[method]
        except KeyError:
            if self.instance is not None:
                # check for a _dispatch method
                if hasattr(self.instance, '_dispatch'):
                    return self.instance._dispatch(request, method, params)
                else:
                    # call instance method directly
                    try:
                        func = resolve_dotted_attribute(
                            self.instance,
                            method,
                            self.allow_dotted_names
                            )
                    except AttributeError:
                        pass

        if func is not None:
            return func(request, *params)
        else:
            raise Exception('method "%s" is not supported' % method)
Exemple #4
0
    def _dispatch(self, method, params):
        """
        Method based on SimpleXMLRPCDispatcher to pass the request object
        as argument.
        """
        func = None
        try:
            # check to see if a matching function has been registered
            func = self.server.funcs[method]
        except KeyError:
            if self.server.instance is not None:
                # check for a _dispatch method
                if hasattr(self.server.instance, '_dispatch'):
                    return self.server.instance._dispatch(method, params)
                else:
                    # call instance method directly
                    try:
                        func = resolve_dotted_attribute(
                            self.server.instance,
                            method,
                            self.server.allow_dotted_names
                            )
                    except AttributeError:
                        pass

        request = Request(
            client_address=self.client_address,
            headers=self.headers,
        )
        if func is not None:
            return func(request, *params)
        else:
            raise Exception('method "%s" is not supported' % method)
Exemple #5
0
    def _getFunc(self, method):
        func = self.funcs.get(method)
        if not func:
            try:
                func = resolve_dotted_attribute(self.instance, method, False)
            except AttributeError:
                pass

        if not func:
            raise Fault(2, 'method "%s" is not supported' % method)

        return func
Exemple #6
0
    def _getFunc(self, method):
        func = self.funcs.get(method)
        if not func:
            try:
                func = resolve_dotted_attribute(
                    self.instance, method, False)
            except AttributeError:
                pass

        if not func:
            raise Fault(2, 'method "%s" is not supported' % method)

        return func
    def generate_html_documentation(self):
        """generate_html_documentation() => html documentation for the server

        Generates HTML documentation for the server using introspection for
        installed functions and instances that do not implement the
        _dispatch method. Alternatively, instances can choose to implement
        the _get_method_argstring(method_name) method to provide the
        argument string used in the documentation and the
        _methodHelp(method_name) method to provide the help text used
        in the documentation."""

        methods = {}

        for method_name in self.system_listMethods():
            if self.funcs.has_key(method_name):
                method = self.funcs[method_name]
            elif self.instance is not None:
                method_info = [None, None] # argspec, documentation
                if hasattr(self.instance, '_get_method_argstring'):
                    method_info[0] = self.instance._get_method_argstring(method_name)
                if hasattr(self.instance, '_methodHelp'):
                    method_info[1] = self.instance._methodHelp(method_name)

                method_info = tuple(method_info)
                if method_info != (None, None):
                    method = method_info
                elif not hasattr(self.instance, '_dispatch'):
                    try:
                        method = resolve_dotted_attribute(
                                    self.instance,
                                    method_name
                                    )
                    except AttributeError:
                        method = method_info
                else:
                    method = method_info
            else:
                assert 0, "Could not find method in self.functions and no "\
                          "instance installed"

            methods[method_name] = method

        documenter = ServerHTMLDoc()
        documentation = documenter.docserver(
                                self.server_name,
                                self.server_documentation,
                                methods
                            )

        return documenter.page(self.server_title, documentation)
Exemple #8
0
    def generate_html_documentation(self):
        """generate_html_documentation() => html documentation for the server

        Generates HTML documentation for the server using introspection for
        installed functions and instances that do not implement the
        _dispatch method. Alternatively, instances can choose to implement
        the _get_method_argstring(method_name) method to provide the
        argument string used in the documentation and the
        _methodHelp(method_name) method to provide the help text used
        in the documentation."""

        methods = {}

        for method_name in self.system_listMethods():
            if method_name in self.funcs:
                method = self.funcs[method_name]
            elif self.instance is not None:
                method_info = [None, None]  # argspec, documentation
                if hasattr(self.instance, '_get_method_argstring'):
                    method_info[0] = self.instance._get_method_argstring(
                        method_name)
                if hasattr(self.instance, '_methodHelp'):
                    method_info[1] = self.instance._methodHelp(method_name)

                method_info = tuple(method_info)
                if method_info != (None, None):
                    method = method_info
                elif not hasattr(self.instance, '_dispatch'):
                    try:
                        method = resolve_dotted_attribute(
                            self.instance, method_name)
                    except AttributeError:
                        method = method_info
                else:
                    method = method_info
            else:
                assert 0, "Could not find method in self.functions and no "\
                          "instance installed"

            methods[method_name] = method

        if self.instance is not None:
            self.recursive_find_methods(methods, self.instance)

        documenter = ServerHTMLDoc()
        documentation = documenter.docserver(self.server_name,
                                             self.server_documentation,
                                             methods)

        return documenter.page(self.server_title, documentation)
Exemple #9
0
    def _dispatch(self, method, params):
        logger.info("recv call: path=%s, method=%s, params=%s", self._path, method, params)
        func = None
        try:
            func = self.funcs[method]
        except KeyError:
            if self.instance is not None:
                if hasattr(self.instance, '_dispatch'):
                    return self.instance._dispatch(method, params)
                else:
                    try:
                        func = resolve_dotted_attribute(self.instance, method, self.allow_dotted_names)
                    except AttributeError:
                        pass

        if func is not None:
            try:
                return func(*params[0], **params[1])
            except:
                logger.exception("Exception:")
                raise
        else:
            raise Exception('method "%s" is not supported' % method)