Update the cookie documentation. Use SimpleCookie instead of SmartCookie/SerialCookie.

This commit is contained in:
Senthil Kumaran 2010-09-22 05:45:14 +00:00
parent 89e87ad13b
commit 4b517db260
1 changed files with 6 additions and 7 deletions

View File

@ -235,8 +235,6 @@ The following example demonstrates how to use the :mod:`Cookie` module.
>>> import Cookie >>> import Cookie
>>> C = Cookie.SimpleCookie() >>> C = Cookie.SimpleCookie()
>>> C = Cookie.SerialCookie()
>>> C = Cookie.SmartCookie()
>>> C["fig"] = "newton" >>> C["fig"] = "newton"
>>> C["sugar"] = "wafer" >>> C["sugar"] = "wafer"
>>> print C # generate HTTP headers >>> print C # generate HTTP headers
@ -245,28 +243,27 @@ The following example demonstrates how to use the :mod:`Cookie` module.
>>> print C.output() # same thing >>> print C.output() # same thing
Set-Cookie: fig=newton Set-Cookie: fig=newton
Set-Cookie: sugar=wafer Set-Cookie: sugar=wafer
>>> C = Cookie.SmartCookie() >>> C = Cookie.SimpleCookie()
>>> C["rocky"] = "road" >>> C["rocky"] = "road"
>>> C["rocky"]["path"] = "/cookie" >>> C["rocky"]["path"] = "/cookie"
>>> print C.output(header="Cookie:") >>> print C.output(header="Cookie:")
Cookie: rocky=road; Path=/cookie Cookie: rocky=road; Path=/cookie
>>> print C.output(attrs=[], header="Cookie:") >>> print C.output(attrs=[], header="Cookie:")
Cookie: rocky=road Cookie: rocky=road
>>> C = Cookie.SmartCookie() >>> C = Cookie.SimpleCookie()
>>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header) >>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
>>> print C >>> print C
Set-Cookie: chips=ahoy Set-Cookie: chips=ahoy
Set-Cookie: vienna=finger Set-Cookie: vienna=finger
>>> C = Cookie.SmartCookie() >>> C = Cookie.SimpleCookie()
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
>>> print C >>> print C
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
>>> C = Cookie.SmartCookie() >>> C = Cookie.SimpleCookie()
>>> C["oreo"] = "doublestuff" >>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/" >>> C["oreo"]["path"] = "/"
>>> print C >>> print C
Set-Cookie: oreo=doublestuff; Path=/ Set-Cookie: oreo=doublestuff; Path=/
>>> C = Cookie.SmartCookie()
>>> C["twix"] = "none for you" >>> C["twix"] = "none for you"
>>> C["twix"].value >>> C["twix"].value
'none for you' 'none for you'
@ -280,6 +277,8 @@ The following example demonstrates how to use the :mod:`Cookie` module.
>>> print C >>> print C
Set-Cookie: number=7 Set-Cookie: number=7
Set-Cookie: string=seven Set-Cookie: string=seven
>>> # SerialCookie and SmartCookie are deprecated
>>> # using it can cause security loopholes in your code.
>>> C = Cookie.SerialCookie() >>> C = Cookie.SerialCookie()
>>> C["number"] = 7 >>> C["number"] = 7
>>> C["string"] = "seven" >>> C["string"] = "seven"