Example #1
0
class RequestStack(object):
    """Store thrift requests."""

    Request = Request

    def __init__(self):
        self.stack = LocalStack()

    def add(self, handler, method, args, kwargs, service_name):
        """Register new request."""
        request = self.Request(handler, method, args, kwargs, service_name)
        self.stack.push(request)
        return request

    @property
    def current(self):
        """Return current request."""
        return self.stack.top

    def to_dict(self):
        return {
            ident: [(request.service_name, request.method.__name__,
                     request.args, request.kwargs)
                    for request in d.get('stack', [])]
            for ident, d in self.stack
        }

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.stack.pop()
Example #2
0
class RequestStack(object):
    """Store thrift requests."""

    Request = Request

    def __init__(self):
        self.stack = LocalStack()

    def add(self, handler, method, args, kwargs, service_name):
        """Register new request."""
        request = self.Request(handler, method, args, kwargs, service_name)
        self.stack.push(request)
        return request

    @property
    def current(self):
        """Return current request."""
        return self.stack.top

    def to_dict(self):
        return {
            ident: [
                (request.service_name, request.method.__name__, request.args, request.kwargs)
                for request in d.get("stack", [])
            ]
            for ident, d in self.stack
        }

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.stack.pop()
Example #3
0
class RequestStack(object):
    """Store thrift requests."""

    Request = Request

    def __init__(self):
        self.stack = LocalStack()

    def add(self, handler, method, args, kwargs, service_name):
        """Register new request."""
        request = self.Request(handler, method, args, kwargs, service_name)
        self.stack.push(request)
        return request

    @property
    def current(self):
        """Return current request."""
        return self.stack.top

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.stack.pop()
Example #4
0
class RequestStack(object):
    """Store thrift requests."""

    Request = Request

    def __init__(self):
        self.stack = LocalStack()

    def add(self, handler, method, args, kwargs, service_name):
        """Register new request."""
        request = self.Request(handler, method, args, kwargs, service_name)
        self.stack.push(request)
        return request

    @property
    def current(self):
        """Return current request."""
        return self.stack.top

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.stack.pop()
Example #5
0
 def __init__(self):
     self.stack = LocalStack()
Example #6
0
 def __init__(self):
     self.stack = LocalStack()