|
import Cookie |
|
|
|
# to fix http://bugs.python.org/issue2193 have to create own SimpleCookie |
|
_LegalChars = Cookie._LegalChars + ":" |
|
|
|
|
|
def _quote(str, LegalChars=_LegalChars, **kwargs): |
|
return Cookie._quote(str, LegalChars=_LegalChars, **kwargs) |
|
|
|
|
|
class Morsel(Cookie.Morsel): |
|
def set(self, key, val, coded_val, LegalChars=_LegalChars, **kwargs): |
|
return super(Morsel, self).set(key, val, coded_val, LegalChars=_LegalChars, **kwargs) |
|
|
|
|
|
class BaseCookie(Cookie.BaseCookie): |
|
def __set(self, key, real_value, coded_value): |
|
"""Private method for setting a cookie's value""" |
|
M = self.get(key, Morsel()) |
|
M.set(key, real_value, coded_value) |
|
dict.__setitem__(self, key, M) |
|
|
|
|
|
class SimpleCookie(BaseCookie): |
|
|
|
def value_decode(self, val): |
|
return Cookie._unquote(val), val |
|
|
|
def value_encode(self, val): |
|
strval = str(val) |
|
return strval, _quote(strval) |