[Python-checkins] r84964 - python/branches/release27-maint/Doc/library/cookie.rst
senthil.kumaran
python-checkins at python.org
Wed Sep 22 07:45:14 CEST 2010
Author: senthil.kumaran
Date: Wed Sep 22 07:45:14 2010
New Revision: 84964
Log:
Update the cookie documentation. Use SimpleCookie instead of SmartCookie/SerialCookie.
Modified:
python/branches/release27-maint/Doc/library/cookie.rst
Modified: python/branches/release27-maint/Doc/library/cookie.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/cookie.rst (original)
+++ python/branches/release27-maint/Doc/library/cookie.rst Wed Sep 22 07:45:14 2010
@@ -235,8 +235,6 @@
>>> import Cookie
>>> C = Cookie.SimpleCookie()
- >>> C = Cookie.SerialCookie()
- >>> C = Cookie.SmartCookie()
>>> C["fig"] = "newton"
>>> C["sugar"] = "wafer"
>>> print C # generate HTTP headers
@@ -245,28 +243,27 @@
>>> print C.output() # same thing
Set-Cookie: fig=newton
Set-Cookie: sugar=wafer
- >>> C = Cookie.SmartCookie()
+ >>> C = Cookie.SimpleCookie()
>>> C["rocky"] = "road"
>>> C["rocky"]["path"] = "/cookie"
>>> print C.output(header="Cookie:")
Cookie: rocky=road; Path=/cookie
>>> print C.output(attrs=[], header="Cookie:")
Cookie: rocky=road
- >>> C = Cookie.SmartCookie()
+ >>> C = Cookie.SimpleCookie()
>>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
>>> print C
Set-Cookie: chips=ahoy
Set-Cookie: vienna=finger
- >>> C = Cookie.SmartCookie()
+ >>> C = Cookie.SimpleCookie()
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
>>> print C
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
- >>> C = Cookie.SmartCookie()
+ >>> C = Cookie.SimpleCookie()
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
>>> print C
Set-Cookie: oreo=doublestuff; Path=/
- >>> C = Cookie.SmartCookie()
>>> C["twix"] = "none for you"
>>> C["twix"].value
'none for you'
@@ -280,6 +277,8 @@
>>> print C
Set-Cookie: number=7
Set-Cookie: string=seven
+ >>> # SerialCookie and SmartCookie are deprecated
+ >>> # using it can cause security loopholes in your code.
>>> C = Cookie.SerialCookie()
>>> C["number"] = 7
>>> C["string"] = "seven"
More information about the Python-checkins
mailing list