Exemplo n.º 1
0
Arquivo: soap.py Projeto: 0004c/VTK
    def render(self, request):
        """Handle a SOAP command."""
        data = request.content.read()

        p, header, body, attrs = SOAPpy.parseSOAPRPC(data, 1, 1, 1)

        methodName, args, kwargs, ns = p._name, p._aslist, p._asdict, p._ns

        # deal with changes in SOAPpy 0.11
        if callable(args):
            args = args()
        if callable(kwargs):
            kwargs = kwargs()

        function = self.lookupFunction(methodName)

        if not function:
            self._methodNotFound(request, methodName)
            return server.NOT_DONE_YET
        else:
            if hasattr(function, "useKeywords"):
                keywords = {}
                for k, v in kwargs.items():
                    keywords[str(k)] = v
                d = defer.maybeDeferred(function, **keywords)
            else:
                d = defer.maybeDeferred(function, *args)

        d.addCallback(self._gotResult, request, methodName)
        d.addErrback(self._gotError, request, methodName)
        return server.NOT_DONE_YET
Exemplo n.º 2
0
    def render(self, request):
        """Handle a SOAP command."""
        data = request.content.read()

        p, header, body, attrs = SOAPpy.parseSOAPRPC(data, 1, 1, 1)

        methodName, args, kwargs, ns = p._name, p._aslist, p._asdict, p._ns

        # deal with changes in SOAPpy 0.11
        if callable(args):
            args = args()
        if callable(kwargs):
            kwargs = kwargs()

        function = self.lookupFunction(methodName)

        if not function:
            self._methodNotFound(request, methodName)
            return server.NOT_DONE_YET
        else:
            if hasattr(function, "useKeywords"):
                keywords = {}
                for k, v in kwargs.items():
                    keywords[str(k)] = v
                d = defer.maybeDeferred(function, **keywords)
            else:
                d = defer.maybeDeferred(function, *args)

        d.addCallback(self._gotResult, request, methodName)
        d.addErrback(self._gotError, request, methodName)
        return server.NOT_DONE_YET
Exemplo n.º 3
0
 def _cbGotResult(self, result):
     result = SOAPpy.parseSOAPRPC(result)
     if hasattr(result, 'Result'):
         return result.Result
     elif len(result) == 1:
         return result[0]
     else:
         return result
Exemplo n.º 4
0
Arquivo: soap.py Projeto: 0004c/VTK
 def _cbGotResult(self, result):
     result = SOAPpy.parseSOAPRPC(result)
     if hasattr(result, 'Result'):
         return result.Result
     elif len(result) == 1:
         ## SOAPpy 0.11.6 wraps the return results in a containing structure.
         ## This check added to make Proxy behaviour emulate SOAPProxy, which
         ## flattens the structure by default.
         ## This behaviour is OK because even singleton lists are wrapped in
         ## another singleton structType, which is almost always useless.
         return result[0]
     else:
         return result
Exemplo n.º 5
0
    def _got_page(self, result):
        """
        The http POST command was successful, we parse the SOAP
        answer, and return it.
        
        @param result: the xml content
        """
        parsed = SOAPpy.parseSOAPRPC(result)

        logging.debug("SOAP Answer:\n%s", result)
        logging.debug("SOAP Parsed Answer: %r", parsed)

        return parsed
Exemplo n.º 6
0
 def _cbGotResult(self, result):
     result = SOAPpy.parseSOAPRPC(result)
     if hasattr(result, 'Result'):
         return result.Result
     elif len(result) == 1:
         ## SOAPpy 0.11.6 wraps the return results in a containing structure.
         ## This check added to make Proxy behaviour emulate SOAPProxy, which
         ## flattens the structure by default.
         ## This behaviour is OK because even singleton lists are wrapped in
         ## another singleton structType, which is almost always useless.
         return result[0]
     else:
         return result
Exemplo n.º 7
0
Arquivo: soap.py Projeto: gyver/p2pool
	def _got_page(self, result):
		"""
		The http POST command was successful, we parse the SOAP
		answer, and return it.
		
		@param result: the xml content
		"""
		parsed = SOAPpy.parseSOAPRPC(result)
		
		logging.debug("SOAP Answer:\n%s", result)
		logging.debug("SOAP Parsed Answer: %r", parsed)
		
		return parsed
Exemplo n.º 8
0
	def _got_error(self, res):
		"""
		The HTTP POST command did not succeed, depending on the error type:
			- it's a SOAP error, we parse it and return a L{SoapError}.
			- it's another type of error (http, other), we raise it as is
		"""
		logging.debug("SOAP Error:\n%s", res)
		
		if isinstance(res.value, error.Error):
			try:
				logging.debug("SOAP Error content:\n%s", res.value.response)
				raise SoapError(SOAPpy.parseSOAPRPC(res.value.response)["detail"])
			except:
				raise
		raise Exception(res.value)
Exemplo n.º 9
0
    def render(self, request):
        # the upload request is multipart/form-data with file and SOAP:
        # handle separately
        if request.postpath == ["upload"]:
            headers = request.requestHeaders
            content_type = headers.getRawHeaders("content-type")[0]
            typ, pdict = cgi.parse_header(content_type)
            #if typ == "multipart/x-url-encoded"
            form = cgi.parse_multipart(request.content, pdict)
            data = form['SOAPENVELOPE'][0]
        else:
            form = None
            data = request.content.read()

        p, header, body, attrs = SOAPpy.parseSOAPRPC(data, 1, 1, 1)
        methodName, args, kwargs, ns = p._name, p._aslist, p._asdict, p._ns

        if callable(args):
            args = args()
        if callable(kwargs):
            kwargs = kwargs()

        if form:
            kwargs["form"] = form
            args.insert(0, form)

        function = self.lookupFunction(methodName)

        if not function:
            self._methodNotFound(request, methodName)
            return server.NOT_DONE_YET
        else:
            if hasattr(function, "useKeywords"):
                keywords = {}
                for k, v in kwargs.items():
                    keywords[str(k)] = v
                d = defer.maybeDeferred(function, **keywords)
            else:
                d = defer.maybeDeferred(function, *args)

        d.addCallback(self._gotResult, request, methodName)
        d.addErrback(self._gotError, request, methodName)
        return server.NOT_DONE_YET
Exemplo n.º 10
0
 def _cbGotResult(self, result):
     return SOAPpy.simplify(SOAPpy.parseSOAPRPC(result))
Exemplo n.º 11
0
 def _cbGotResult(self, result):
     return SOAPpy.simplify(SOAPpy.parseSOAPRPC(result))