Пример #1
0
    def __call__(self, *args, **kwargs):
        ctx = MethodContext(self.__app)
        ctx.method_name = self.__key
        ctx.in_header = self.__in_header

        ctx.service_class = self.__app.get_service_class(ctx.method_name)
        ctx.descriptor = ctx.service_class.get_method(ctx.method_name)

        self.__app.process_request(ctx, args)

        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