[Python-checkins] CVS: python/dist/src/Lib Cookie.py,1.1,1.2
A.M. Kuchling
python-dev@python.org
Thu, 24 Aug 2000 04:52:36 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory slayer.i.sourceforge.net:/tmp/cvs-serv27590
Modified Files:
Cookie.py
Log Message:
Updated version of Cookie.py (rev. 2.29) from timo
Index: Cookie.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Cookie.py 2000/08/19 13:01:19 1.1
--- Cookie.py 2000/08/24 11:52:33 1.2
***************
*** 27,31 ****
####
#
! # $Id$
# by Timothy O'Malley <timo@alum.mit.edu>
#
--- 27,31 ----
####
#
! # Id: Cookie.py,v 2.29 2000/08/23 05:28:49 timo Exp
# by Timothy O'Malley <timo@alum.mit.edu>
#
***************
*** 35,39 ****
#
# The original idea to treat Cookies as a dictionary came from
! # Dave Mitchel (davem@magnet.com) in 1995, when he released the
# first version of nscookie.py.
#
--- 35,39 ----
#
# The original idea to treat Cookies as a dictionary came from
! # Dave Mitchell (davem@magnet.com) in 1995, when he released the
# first version of nscookie.py.
#
***************
*** 70,74 ****
>>> C["fig"] = "newton"
>>> C["sugar"] = "wafer"
! >>> C
Set-Cookie: sugar=wafer;
Set-Cookie: fig=newton;
--- 70,74 ----
>>> C["fig"] = "newton"
>>> C["sugar"] = "wafer"
! >>> print C
Set-Cookie: sugar=wafer;
Set-Cookie: fig=newton;
***************
*** 93,97 ****
>>> C = Cookie.SmartCookie()
>>> C.load("chips=ahoy; vienna=finger")
! >>> C
Set-Cookie: vienna=finger;
Set-Cookie: chips=ahoy;
--- 93,97 ----
>>> C = Cookie.SmartCookie()
>>> C.load("chips=ahoy; vienna=finger")
! >>> print C
Set-Cookie: vienna=finger;
Set-Cookie: chips=ahoy;
***************
*** 103,107 ****
>>> C = Cookie.SmartCookie()
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
! >>> C
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;";
--- 103,107 ----
>>> C = Cookie.SmartCookie()
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
! >>> print C
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;";
***************
*** 113,117 ****
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
! >>> C
Set-Cookie: oreo="doublestuff"; Path=/;
--- 113,117 ----
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
! >>> print C
Set-Cookie: oreo="doublestuff"; Path=/;
***************
*** 145,149 ****
>>> C["string"].value
'seven'
! >>> C
Set-Cookie: number=7;
Set-Cookie: string=seven;
--- 145,149 ----
>>> C["string"].value
'seven'
! >>> print C
Set-Cookie: number=7;
Set-Cookie: string=seven;
***************
*** 166,170 ****
>>> C["string"].value
'seven'
! >>> C
Set-Cookie: number="I7\012.";
Set-Cookie: string="S'seven'\012p1\012.";
--- 166,170 ----
>>> C["string"].value
'seven'
! >>> print C
Set-Cookie: number="I7\012.";
Set-Cookie: string="S'seven'\012p1\012.";
***************
*** 191,195 ****
>>> C["string"].value
'seven'
! >>> C
Set-Cookie: number="I7\012.";
Set-Cookie: string=seven;
--- 191,195 ----
>>> C["string"].value
'seven'
! >>> print C
Set-Cookie: number="I7\012.";
Set-Cookie: string=seven;
***************
*** 310,314 ****
def _quote(str, LegalChars=_LegalChars,
! join=string.join, idmap=string._idmap, translate=string.translate):
#
# If the string does not need to be double-quoted,
--- 310,314 ----
def _quote(str, LegalChars=_LegalChars,
! join=string.join, idmap=string._idmap, translate=string.translate):
#
# If the string does not need to be double-quoted,
***************
*** 318,324 ****
#
if "" == translate(str, idmap, LegalChars):
! return str
else:
! return '"' + join( map(_Translator.get, str, str), "" ) + '"'
# end _quote
--- 318,324 ----
#
if "" == translate(str, idmap, LegalChars):
! return str
else:
! return '"' + join( map(_Translator.get, str, str), "" ) + '"'
# end _quote
***************
*** 441,445 ****
def isReservedKey(self, K):
! return string.lower(K) in self._reserved_keys
# end isReservedKey
--- 441,445 ----
def isReservedKey(self, K):
! return string.lower(K) in self._reserved_keys
# end isReservedKey
***************
*** 463,468 ****
return "%s %s" % ( header, self.OutputString(attrs) )
! __repr__ = output
def js_output(self, attrs=None):
# Print javascript
--- 463,472 ----
return "%s %s" % ( header, self.OutputString(attrs) )
! __str__ = output
+ def __repr__(self):
+ return '<%s: %s=%s>' % (self.__class__.__name__,
+ self.key, repr(self.value) )
+
def js_output(self, attrs=None):
# Print javascript
***************
*** 489,493 ****
attrs = self._reserved_keys
for K,V in self.items():
! if not V: continue
if K not in attrs: continue
if K == "expires" and type(V) == type(1):
--- 493,497 ----
attrs = self._reserved_keys
for K,V in self.items():
! if V == "": continue
if K not in attrs: continue
if K == "expires" and type(V) == type(1):
***************
*** 586,591 ****
# end output
! __repr__ = output
!
def js_output(self, attrs=None):
"""Return a string suitable for JavaScript."""
--- 590,601 ----
# end output
! __str__ = output
!
! def __repr__(self):
! L = []
! for K,V in self.items():
! L.append( '%s=%s' % (K,repr(V.value) ) )
! return '<%s: %s>' % (self.__class__.__name__, string.join(L))
!
def js_output(self, attrs=None):
"""Return a string suitable for JavaScript."""
***************
*** 631,635 ****
elif string.lower(K) in Morsel._reserved_keys:
if M:
! M[ K ] = V
else:
rval, cval = self.value_decode(V)
--- 641,645 ----
elif string.lower(K) in Morsel._reserved_keys:
if M:
! M[ K ] = _unquote(V)
else:
rval, cval = self.value_decode(V)
***************
*** 637,641 ****
M = self[K]
! return
# end __ParseString
# end BaseCookie class
--- 647,651 ----
M = self[K]
! return
# end __ParseString
# end BaseCookie class
***************
*** 717,718 ****
--- 727,732 ----
# should add a test routine?
#
+
+ #Local Variables:
+ #tab-width: 4
+ #end: