Esempio n. 1
0
class _Serving(_local):
    """An interface for registering request and response objects.

    Rather than have a separate "thread local" object for the request and
    the response, this class works as a single threadlocal container for
    both objects (and any others which developers wish to define). In this
    way, we can easily dump those objects when we stop/start a new HTTP
    conversation, yet still refer to them as module-level globals in a
    thread-safe way.
    """

    request = _cprequest.Request(_httputil.Host("127.0.0.1", 80),
                                 _httputil.Host("127.0.0.1", 1111))
    """
    The request object for the current thread. In the main thread,
    and any threads which are not receiving HTTP requests, this is None."""

    response = _cprequest.Response()
    """
    The response object for the current thread. In the main thread,
    and any threads which are not receiving HTTP requests, this is None."""
    def load(self, request, response):
        self.request = request
        self.response = response

    def clear(self):
        """Remove all attributes of self."""
        self.__dict__.clear()
Esempio n. 2
0
 def __init__(self):
     object.__setattr__(self, '__local__', {})
     ident = get_ident()
     self.__local__[ident] = {
         'request': _cprequest.Request(httputil.Host("127.0.0.1", 80), httputil.Host("127.0.0.1", 1111)),
         'response': _cprequest.Response()
     }
Esempio n. 3
0
class _Serving(_local):
    request = _cprequest.Request(_httputil.Host('127.0.0.1', 80), _httputil.Host('127.0.0.1', 1111))
    response = _cprequest.Response()

    def load(self, request, response):
        self.request = request
        self.response = response

    def clear(self):
        self.__dict__.clear()