Пример #1
0
    def __init__(self, app, req_env, content_type):
        self.http_req_env = req_env
        self.http_resp_headers = {
            'Content-Type': content_type,
            'Content-Length': '0',
        }
        self.wsdl_error = None

        MethodContext.__init__(self, app)
Пример #2
0
    def __init__(self, url, app, name, out_header=None):
        self.url = url
        self.app = app

        initial_ctx = MethodContext(self)
        initial_ctx.method_request_string = name
        initial_ctx.out_header = out_header

        self.contexts = self.app.out_protocol.generate_method_contexts(initial_ctx)
Пример #3
0
    def __init__(self, url, app, name, out_header=None):
        self.url = url
        self.app = app

        initial_ctx = MethodContext(app)
        initial_ctx.method_request_string = name
        initial_ctx.out_header = out_header

        self.contexts = self.app.out_protocol.generate_method_contexts(
            initial_ctx)
Пример #4
0
    def __call__(self, *args, **kwargs):
        initial_ctx = MethodContext(self.__app)
        initial_ctx.method_request_string = self.__key
        initial_ctx.in_header = self.__in_header
        initial_ctx.in_object = args

        contexts = self.__app.in_protocol.generate_method_contexts(initial_ctx)
        for ctx in contexts:
            # set logging.getLogger('rpclib.server.null').setLevel(logging.CRITICAL)
            # to hide the following
            _header = ('=' * 30) + LIGHT_RED
            _footer = END_COLOR + ('=' * 30)

            logger.warning( "%s start request %s" % (_header, _footer)  )
            self.__app.process_request(ctx)
            logger.warning( "%s  end request  %s" % (_header, _footer)  )

            if ctx.out_error:
                raise ctx.out_error

            else:
                if len(ctx.descriptor.out_message._type_info) == 0:
                    retval = None

                elif len(ctx.descriptor.out_message._type_info) == 1:
                    retval = ctx.out_object[0]

                    # workaround to have the context disposed of when the caller is done
                    # with the return value. the context is sometimes needed to fully
                    # construct the return object (e.g. when the object is a sqlalchemy
                    # object bound to a session that's defined in the context object).
                    try:
                        retval.__ctx__ = ctx
                    except AttributeError:
                        # not all objects let this happen. (eg. built-in types like str)
                        # which don't need the context anyway.
                        pass

                else:
                    retval = ctx.out_object

                    # same as above
                    try:
                        retval[0].__ctx__ = ctx
                    except AttributeError:
                        pass

        return retval
Пример #5
0
    def __call__(self, *args, **kwargs):
        ctx = MethodContext(self.__app)
        ctx.method_request_string = self.__key
        ctx.in_header = self.__in_header
        ctx.in_object = args

        self.__app.in_protocol.set_method_descriptor(ctx)
        self.__app.process_request(ctx)

        if ctx.out_error:
            raise ctx.out_error
        else:
            # workaround to have the context be disposed when the caller is done
            # with the return value. the context is sometimes needed to fully
            # construct the return object.
            try:
                ctx.out_object.__ctx__ = ctx
            except AttributeError,e:
                # not all objects let this happen. (eg. built-in types like str)
                # which don't need the context anyway.
                pass

            return ctx.out_object
Пример #6
0
 def rootPage(self, *args, **kwargs):
     """Handle an incoming SOAP request or a non-SOAP WSDL query."""
     self.response.content_type = 'text/xml'
     if not self.request._request.body:
         return self.service_description()
     if True:
         ctx = MethodContext()
         in_string = collapse_swa(self.request.content_type,
                                  self.request._request.body)
         in_obj = self.get_in_object(ctx, in_string,
                                     self.request._request.charset)
         out_obj = self.get_out_object(ctx, in_obj)
         out_string = self.get_out_string(ctx, out_obj)
         return out_string
     else:
         #except Exception, e:
         if getattr(self, 'debug_soap', False):
             raise
         self.response.status = '500 Internal Server Error'
         fault = Fault(faultstring=str(e))
         resp = etree.tostring(fault, encoding=string_encoding)
         return resp
Пример #7
0
 def __init__(self, app):
     MethodContext.__init__(self, app)
     self.transport.type = 'zmq'
Пример #8
0
    def __init__(self, app, req_env, content_type):
        self.http_req_env = req_env
        self.http_resp_headers = {"Content-Type": content_type, "Content-Length": "0"}
        self.wsdl_error = None

        MethodContext.__init__(self, app)
Пример #9
0
 def __init__(self, app):
     MethodContext.__init__(self, app)
     self.transport.type = 'zmq'