@@ -0,0 +1,2340 @@
+from datetime import datetime%0Afrom time import time, gmtime%0Afrom Cookie import SimpleCookie, Morsel%0A%0A%0Adef set_cookie_date(expires):%0A    %22%22%22Outputs a string in the format %22 Thu, DD-MM-YYYY HH:MM:SS GMT %22.%22%22%22%0A    if isinstance(expires, datetime):%0A        expires = expires.utctimetuple()%0A    elif isinstance(expires, (int, float, long)):%0A        expires = gmtime(expires)%0A%0A    return '%25s, %2502d-%25s-%25s %2502d:%2502d:%2502d GMT' %25 (%0A        ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')%5Bexpires.tm_wday%5D,%0A        expires.tm_mday,%0A        ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',%0A         'Oct', 'Nov', 'Dec')%5Bexpires.tm_mon - 1%5D,%0A        str(expires.tm_year), expires.tm_hour, expires.tm_min, expires.tm_sec%0A    )%0A%0A%0Adef parse_cookie(environ):%0A    raw_cookie = SimpleCookie(environ.get('HTTP_COOKIE', ''))%0A    cookie = %7B%7D%0A    for key, value in raw_cookie.iteritems():%0A        cookie%5Bkey%5D = value%0A    return cookie%0A%0A%0Adef generate_cookie(key, value, expires=None, path='/', domain=None,%0A                    max_age=None, secure=None, httponly=False):%0A    %22%22%22Generate a cookie. Called by the function of set_cookie(). The params are%0A    the same as the Morsel object in the Cookie which is a Python Standard Library.%0A%0A    :param key: the name of the cookie to be set%0A    :param value: the value of the cookie%0A    :param expires: should be a %60datetime%60 object or UNIX timestamp.%0A    :param path: limit the cookie to the given path.%0A    :param domain: set a cross-domain cookie. Example:%0A                   domain=%22.example.com%22, it will set the cookie that is%0A                   readable by the domain %22www.example.com%22%0A    :param max_age: should be a number of seconds or None.%0A    :param secure: The cookie will only be available via HTTPS%0A    %22%22%22%0A%0A    morsel = Morsel()%0A    if key is not None:%0A        morsel.set(key, value, value)%0A%0A    if expires is not None:%0A        if not isinstance(expires, basestring):%0A            expires = set_cookie_date(expires)%0A        morsel%5B'expires'%5D = expires%0A    elif max_age is not None:%0A        morsel%5B'expires'%5D = set_cookie_date(time() + max_age)%0A%0A    for key, value in (('path', path), ('domain', domain),%0A                       ('secure', secure), ('httponly', httponly)):%0A        if value is not None and value is not False:%0A            morsel%5Bkey%5D = value%0A%0A    return morsel.output()%0A%0A

Add handling cookies methods.