Beispiel #1
0
    def _marshaled_dispatch(self, data, dispatch_method=None, path=None):
        """Dispatches an XML-RPC method from marshalled (XML) data.

        XML-RPC methods are dispatched from the marshalled (XML) data
        using the _dispatch method and the result is returned as
        marshalled data. For backwards compatibility, a dispatch
        function can be provided as an argument (see comment in
        SimpleXMLRPCRequestHandler.do_POST) but overriding the
        existing method through subclassing is the preferred means
        of changing method dispatch behavior.
        """

        try:
            params, method = loads(data,
                                   use_builtin_types=self.use_builtin_types)

            # generate response
            if dispatch_method is not None:
                response = dispatch_method(method, params)
            else:
                response = self._dispatch(method, params)
            # wrap response in a singleton tuple
            response = (response, )
            response = dumps(
                response,
                methodresponse=1,
                allow_none=self.allow_none,
                encoding=self.encoding,
            )
        except Fault as fault:
            response = dumps(fault,
                             allow_none=self.allow_none,
                             encoding=self.encoding)
        except:
            # report exception back to server
            exc_type, exc_value, exc_tb = sys.exc_info()
            response = dumps(
                Fault(1, "%s:%s" % (exc_type, exc_value)),
                encoding=self.encoding,
                allow_none=self.allow_none,
            )

        return response.encode(self.encoding)
 def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
     try:
         response = self.dispatchers[path]._marshaled_dispatch(
            data, dispatch_method, path)
     except:
         # report low level exception back to server
         # (each dispatcher should have handled their own
         # exceptions)
         exc_type, exc_value = sys.exc_info()[:2]
         response = dumps(
             Fault(1, "%s:%s" % (exc_type, exc_value)),
             encoding=self.encoding, allow_none=self.allow_none)
         response = response.encode(self.encoding)
     return response
Beispiel #3
0
 def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
     try:
         response = self.dispatchers[path]._marshaled_dispatch(
            data, dispatch_method, path)
     except:
         # report low level exception back to server
         # (each dispatcher should have handled their own
         # exceptions)
         exc_type, exc_value = sys.exc_info()[:2]
         response = dumps(
             Fault(1, "%s:%s" % (exc_type, exc_value)),
             encoding=self.encoding, allow_none=self.allow_none)
         response = response.encode(self.encoding)
     return response
Beispiel #4
0
    def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
        """Dispatches an XML-RPC method from marshalled (XML) data.

        XML-RPC methods are dispatched from the marshalled (XML) data
        using the _dispatch method and the result is returned as
        marshalled data. For backwards compatibility, a dispatch
        function can be provided as an argument (see comment in
        SimpleXMLRPCRequestHandler.do_POST) but overriding the
        existing method through subclassing is the preferred means
        of changing method dispatch behavior.
        """

        try:
            params, method = loads(data, use_builtin_types=self.use_builtin_types)

            # generate response
            if dispatch_method is not None:
                response = dispatch_method(method, params)
            else:
                response = self._dispatch(method, params)
            # wrap response in a singleton tuple
            response = (response,)
            response = dumps(response, methodresponse=1,
                             allow_none=self.allow_none, encoding=self.encoding)
        except Fault as fault:
            response = dumps(fault, allow_none=self.allow_none,
                             encoding=self.encoding)
        except:
            # report exception back to server
            exc_type, exc_value, exc_tb = sys.exc_info()
            response = dumps(
                Fault(1, "%s:%s" % (exc_type, exc_value)),
                encoding=self.encoding, allow_none=self.allow_none,
                )

        return response.encode(self.encoding)