@@ -0,0 +1,2449 @@
+from Cookie import SimpleCookie%0A%0A%0AENVIRON_KEY = 'wsgiapptools.cookies'%0A%0A%0Adef get_cookie_cutter(environ):%0A    %22%22%22%0A    Find the CookieCutter instance from the WSGI environ.%0A    %22%22%22%0A    return environ%5BENVIRON_KEY%5D%0A%0A%0Aclass CookieCutter(object):%0A    %22%22%22%0A    Cookie manager, associated with a WSGI environ.%0A    %22%22%22%0A%0A    def __init__(self, environ):%0A        self.environ = environ%0A        self.headers = %5B%5D%0A%0A    def set_cookie(self, cookie):%0A        %22%22%22%0A        Set a cookie.%0A%0A        The cookie will actually be recorded in the WSGI environ and the%0A        'Set-Cookie' header will be generated with the responses are first%0A        sent.%0A%0A        'cookie' can be one of four things:%0A%0A            * a string: the value is considered a cookie header value, i.e. the%0A              bit that would normally be added after 'Set-Cookie: '.%0A            * (name, value) tuple: a persistent cookie is created.%0A            * (name, None) tuple: the named cookie will be removed.%0A            * cookie instance: e.g. one of the cookie types in Python's Cookie%0A              module.%0A        %22%22%22%0A        if isinstance(cookie, str):%0A            pass%0A        elif isinstance(cookie, tuple):%0A            name, value = cookie%0A            cookie = SimpleCookie()%0A            cookie%5Bname%5D = value or ''%0A            cookie%5Bname%5D%5B'path'%5D = self.environ%5B'SCRIPT_NAME'%5D or '/'%0A            if value is None:%0A                cookie%5Bname%5D%5B'expires'%5D = 0%0A                cookie%5Bname%5D%5B'max-age'%5D = 0%0A            cookie = cookie.output(header='').strip()%0A        else:%0A            cookie = cookie.output(header='').strip()%0A        self.headers.append(cookie)%0A%0A    def delete_cookie(self, cookie_name):%0A        %22%22%22%0A        Delete the named cookie.%0A        %22%22%22%0A        self.set_cookie((cookie_name, None))%0A%0A%0Adef middleware_factory(app):%0A    %22%22%22%0A    Create a cookie middleware WSGI application around the given WSGI%0A    application.%0A    %22%22%22%0A    def middleware(environ, start_response):%0A        def _start_response(status, response_headers, exc_info=None):%0A            # Extend the headers with cookie setting headers.%0A            cutter = environ%5BENVIRON_KEY%5D%0A            response_headers.extend(('Set-Cookie', header) for header in cutter.headers)%0A            # Call wrapped app's start_response.%0A            return start_response(status, response_headers, exc_info)%0A        environ%5BENVIRON_KEY%5D = CookieCutter(environ)%0A        return app(environ, _start_response)%0A    return middleware%0A%0A

Add cookies module.