(self, environ, start_response)
return output
Parse an XMLRPC body for the method, and call it with the
        appropriate arguments
Parse an XMLRPC body for the method, and call it with the
        appropriate arguments
Parse an XMLRPC body for the method and call it with the appropriate arguments
def __call__(self, environ, start_response):
        """Parse an XMLRPC body for the method, and call it with the
        appropriate arguments"""
        # Pull out the length, return an error if there is no valid
        # length or if the length is larger than the max_body_length.
        log_debug = self._pylons_log_debug
        length = environ.get('CONTENT_LENGTH')
        if length:
            length = int(length)
        else:
            # No valid Content-Length header found
            if log_debug:
                log.debug("No Content-Length found, returning 411 error")
            abort(411)
        if length > self.max_body_length or length == 0:
            if log_debug:
                log.debug("Content-Length larger than max body length. Max: "
                          "%s, Sent: %s. Returning 413 error",
                          self.max_body_length, length)
            abort(413, "XML body too large")

        body = environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
        rpc_args, orig_method = xmlrpclib.loads(body)

        method = self._find_method_name(orig_method)
        func = self._find_method(method)
        if not func:
            if log_debug:
                log.debug("Method: %r not found, returning xmlrpc fault",
                          method)
            return xmlrpc_fault(0, "No such method name %r" %
                                method)(environ, start_response)

        # Signature checking for params
        if hasattr(func, 'signature'):
            if log_debug:
                log.debug("Checking XMLRPC argument signature")
            valid_args = False
            params = xmlrpc_sig(rpc_args)
            for sig in func.signature:
                # Next sig if we don't have the same amount of args
                if len(sig) - 1 != len(rpc_args):
                    continue

                # If the params match, we're valid
                if params == sig[1:]:
                    valid_args = True
                    break

            if not valid_args:
                if log_debug:
                    log.debug("Bad argument signature recieved, returning "
                              "xmlrpc fault")
                msg = ("Incorrect argument signature. %r recieved does not "
                       "match %r signature for method %r" % \
                           (params, func.signature, orig_method))
                return xmlrpc_fault(0, msg)(environ, start_response)

        # Change the arg list into a keyword dict based off the arg
        # names in the functions definition
        arglist = inspect.getargspec(func)[0][1:]
        kargs = dict(zip(arglist, rpc_args))
        kargs['action'], kargs['environ'] = method, environ
        kargs['start_response'] = start_response
        self.rpc_kargs = kargs
        self._func = func

        # Now that we know the method is valid, and the args are valid,
        # we can dispatch control to the default WSGIController
        status = []
        headers = []
        exc_info = []

        def change_content(new_status, new_headers, new_exc_info=None):
            status.append(new_status)
            headers.extend(new_headers)
            exc_info.append(new_exc_info)
        output = WSGIController.__call__(self, environ, change_content)
        output = list(output)
        headers.append(('Content-Length', str(len(output[0]))))
        replace_header(headers, 'Content-Type', 'text/xml')
        start_response(status[0], headers, exc_info[0])
        return output
def __call__ ( self , environ , start_response ) : # Pull out the length, return an error if there is no valid # length or if the length is larger than the max_body_length. log_debug = self . _pylons_log_debug length = environ . get ( 'CONTENT_LENGTH' ) if length : length = int ( length ) else : # No valid Content-Length header found if log_debug : log . debug ( "No Content-Length found, returning 411 error" ) abort ( 411 ) if length > self . max_body_length or length == 0 : if log_debug : log . debug ( "Content-Length larger than max body length. Max: " "%s, Sent: %s. Returning 413 error" , self . max_body_length , length ) abort ( 413 , "XML body too large" ) body = environ [ 'wsgi.input' ] . read ( int ( environ [ 'CONTENT_LENGTH' ] ) ) rpc_args , orig_method = xmlrpclib . loads ( body ) method = self . _find_method_name ( orig_method ) func = self . _find_method ( method ) if not func : if log_debug : log . debug ( "Method: %r not found, returning xmlrpc fault" , method ) return xmlrpc_fault ( 0 , "No such method name %r" % method ) ( environ , start_response ) # Signature checking for params if hasattr ( func , 'signature' ) : if log_debug : log . debug ( "Checking XMLRPC argument signature" ) valid_args = False params = xmlrpc_sig ( rpc_args ) for sig in func . signature : # Next sig if we don't have the same amount of args if len ( sig ) - 1 != len ( rpc_args ) : continue # If the params match, we're valid if params == sig [ 1 : ] : valid_args = True break if not valid_args : if log_debug : log . debug ( "Bad argument signature recieved, returning " "xmlrpc fault" ) msg = ( "Incorrect argument signature. %r recieved does not " "match %r signature for method %r" % ( params , func . signature , orig_method ) ) return xmlrpc_fault ( 0 , msg ) ( environ , start_response ) # Change the arg list into a keyword dict based off the arg # names in the functions definition arglist = inspect . getargspec ( func ) [ 0 ] [ 1 : ] kargs = dict ( zip ( arglist , rpc_args ) ) kargs [ 'action' ] , kargs [ 'environ' ] = method , environ kargs [ 'start_response' ] = start_response self . rpc_kargs = kargs self . _func = func # Now that we know the method is valid, and the args are valid, # we can dispatch control to the default WSGIController status = [ ] headers = [ ] exc_info = [ ] def change_content ( new_status , new_headers , new_exc_info = None ) : status . append ( new_status ) headers . extend ( new_headers ) exc_info . append ( new_exc_info ) output = WSGIController . __call__ ( self , environ , change_content ) output = list ( output ) headers . append ( ( 'Content-Length' , str ( len ( output [ 0 ] ) ) ) ) replace_header ( headers , 'Content-Type' , 'text/xml' ) start_response ( status [ 0 ] , headers , exc_info [ 0 ] ) return output