Back to index

python3.2  3.2.2
Classes | Functions | Variables
http.cookies Namespace Reference

Classes

class  CookieError
class  Morsel

Functions

def _quote
def _unquote
def _getdate

Variables

list __all__ = ["CookieError", "BaseCookie", "SimpleCookie"]
string _nulljoin = ''
string _semispacejoin = '; '
string _spacejoin = ' '
string _LegalChars = "!#$%&'*+-.^_`|~"
dictionary _Translator
tuple _OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")
tuple _QuotePatt = re.compile(r"[\\].")
list _weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
list _monthname
string _LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]"

Function Documentation

def http.cookies._getdate (   future = 0,
  weekdayname = _weekdayname,
  monthname = _monthname 
) [private]

Definition at line 300 of file cookies.py.

00300 
00301 def _getdate(future=0, weekdayname=_weekdayname, monthname=_monthname):
00302     from time import gmtime, time
00303     now = time()
00304     year, month, day, hh, mm, ss, wd, y, z = gmtime(now + future)
00305     return "%s, %02d-%3s-%4d %02d:%02d:%02d GMT" % \
00306            (weekdayname[wd], day, monthname[month], year, hh, mm, ss)
00307 

Here is the caller graph for this function:

def http.cookies._quote (   str,
  LegalChars = _LegalChars 
) [private]

Definition at line 228 of file cookies.py.

00228 
00229 def _quote(str, LegalChars=_LegalChars):
00230     r"""Quote a string for use in a cookie header.
00231 
00232     If the string does not need to be double-quoted, then just return the
00233     string.  Otherwise, surround the string in doublequotes and quote
00234     (with a \) special characters.
00235     """
00236     if all(c in LegalChars for c in str):
00237         return str
00238     else:
00239         return '"' + _nulljoin(_Translator.get(s, s) for s in str) + '"'
00240 

def http.cookies._unquote (   str) [private]

Definition at line 244 of file cookies.py.

00244 
00245 def _unquote(str):
00246     # If there aren't any doublequotes,
00247     # then there can't be any special characters.  See RFC 2109.
00248     if len(str) < 2:
00249         return str
00250     if str[0] != '"' or str[-1] != '"':
00251         return str
00252 
00253     # We have to assume that we must decode this string.
00254     # Down to work.
00255 
00256     # Remove the "s
00257     str = str[1:-1]
00258 
00259     # Check for special sequences.  Examples:
00260     #    \012 --> \n
00261     #    \"   --> "
00262     #
00263     i = 0
00264     n = len(str)
00265     res = []
00266     while 0 <= i < n:
00267         o_match = _OctalPatt.search(str, i)
00268         q_match = _QuotePatt.search(str, i)
00269         if not o_match and not q_match:              # Neither matched
00270             res.append(str[i:])
00271             break
00272         # else:
00273         j = k = -1
00274         if o_match:
00275             j = o_match.start(0)
00276         if q_match:
00277             k = q_match.start(0)
00278         if q_match and (not o_match or k < j):     # QuotePatt matched
00279             res.append(str[i:k])
00280             res.append(str[k+1])
00281             i = k + 2
00282         else:                                      # OctalPatt matched
00283             res.append(str[i:j])
00284             res.append(chr(int(str[j+1:j+4], 8)))
00285             i = j + 4
00286     return _nulljoin(res)
00287 
00288 # The _getdate() routine is used to set the expiration time in the cookie's HTTP
00289 # header.  By default, _getdate() returns the current time in the appropriate
00290 # "expires" format for a Set-Cookie header.  The one optional argument is an
00291 # offset from now, in seconds.  For example, an offset of -3600 means "one hour
00292 # ago".  The offset may be a floating point number.
00293 #

Here is the call graph for this function:


Variable Documentation

list http.cookies.__all__ = ["CookieError", "BaseCookie", "SimpleCookie"]

Definition at line 138 of file cookies.py.

string http.cookies._LegalChars = "!#$%&'*+-.^_`|~"

Definition at line 162 of file cookies.py.

string http.cookies._LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]"

Definition at line 432 of file cookies.py.

Initial value:
00001 [None,
00002               'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
00003               'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

Definition at line 296 of file cookies.py.

Definition at line 140 of file cookies.py.

tuple http.cookies._OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")

Definition at line 241 of file cookies.py.

Definition at line 242 of file cookies.py.

Definition at line 141 of file cookies.py.

Definition at line 142 of file cookies.py.

Definition at line 163 of file cookies.py.

list http.cookies._weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

Definition at line 294 of file cookies.py.