mirror of
https://github.com/python/cpython.git
synced 2025-11-11 22:55:08 +00:00
Fix the example (it didn't seem to reflect reality).
This commit is contained in:
parent
6f477a6c07
commit
3a9582fbe5
1 changed files with 14 additions and 12 deletions
|
|
@ -173,19 +173,21 @@ The meaning for \var{attrs} is the same as in \method{output()}.
|
||||||
|
|
||||||
\subsection{Example \label{cookie-example}}
|
\subsection{Example \label{cookie-example}}
|
||||||
|
|
||||||
The following example demonstrates how to open a can of spam using the
|
The following example demonstrates how to use the \module{Cookie} module.
|
||||||
\module{spam} module.
|
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
>>> import Cookie
|
>>> import Cookie
|
||||||
>>> C = Cookie.SimpleCookie()
|
>>> C = Cookie.SimpleCookie()
|
||||||
>>> C = Cookie.SerialCookie()
|
>>> C = Cookie.SerialCookie()
|
||||||
>>> C = Cookie.SmartCookie()
|
>>> C = Cookie.SmartCookie()
|
||||||
>>> C = Cookie.Cookie() # backwards compatible alias for SmartCookie
|
>>> C = Cookie.Cookie() # backwards-compatible alias for SmartCookie
|
||||||
>>> C = Cookie.SmartCookie()
|
>>> C = Cookie.SmartCookie()
|
||||||
>>> C["fig"] = "newton"
|
>>> C["fig"] = "newton"
|
||||||
>>> C["sugar"] = "wafer"
|
>>> C["sugar"] = "wafer"
|
||||||
>>> C # generate HTTP headers
|
>>> print C # generate HTTP headers
|
||||||
|
Set-Cookie: sugar=wafer;
|
||||||
|
Set-Cookie: fig=newton;
|
||||||
|
>>> print C.output() # same thing
|
||||||
Set-Cookie: sugar=wafer;
|
Set-Cookie: sugar=wafer;
|
||||||
Set-Cookie: fig=newton;
|
Set-Cookie: fig=newton;
|
||||||
>>> C = Cookie.SmartCookie()
|
>>> C = Cookie.SmartCookie()
|
||||||
|
|
@ -197,18 +199,18 @@ Cookie: rocky=road; Path=/cookie;
|
||||||
Cookie: rocky=road;
|
Cookie: rocky=road;
|
||||||
>>> C = Cookie.SmartCookie()
|
>>> C = Cookie.SmartCookie()
|
||||||
>>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
|
>>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
|
||||||
>>> C
|
>>> print C
|
||||||
Set-Cookie: vienna=finger;
|
Set-Cookie: vienna=finger;
|
||||||
Set-Cookie: chips=ahoy;
|
Set-Cookie: chips=ahoy;
|
||||||
>>> C = Cookie.SmartCookie()
|
>>> C = Cookie.SmartCookie()
|
||||||
>>> C.load('keebler="E=everybody; L=\"Loves\"; fudge=\012;";')
|
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
|
||||||
>>> 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.SmartCookie()
|
||||||
>>> C["oreo"] = "doublestuff"
|
>>> C["oreo"] = "doublestuff"
|
||||||
>>> C["oreo"]["path"] = "/"
|
>>> C["oreo"]["path"] = "/"
|
||||||
>>> C
|
>>> print C
|
||||||
Set-Cookie: oreo="doublestuff"; Path=/;
|
Set-Cookie: oreo=doublestuff; Path=/;
|
||||||
>>> C = Cookie.SmartCookie()
|
>>> C = Cookie.SmartCookie()
|
||||||
>>> C["twix"] = "none for you"
|
>>> C["twix"] = "none for you"
|
||||||
>>> C["twix"].value
|
>>> C["twix"].value
|
||||||
|
|
@ -220,7 +222,7 @@ Set-Cookie: oreo="doublestuff"; Path=/;
|
||||||
'7'
|
'7'
|
||||||
>>> C["string"].value
|
>>> C["string"].value
|
||||||
'seven'
|
'seven'
|
||||||
>>> C
|
>>> print C
|
||||||
Set-Cookie: number=7;
|
Set-Cookie: number=7;
|
||||||
Set-Cookie: string=seven;
|
Set-Cookie: string=seven;
|
||||||
>>> C = Cookie.SerialCookie()
|
>>> C = Cookie.SerialCookie()
|
||||||
|
|
@ -230,7 +232,7 @@ Set-Cookie: string=seven;
|
||||||
7
|
7
|
||||||
>>> C["string"].value
|
>>> C["string"].value
|
||||||
'seven'
|
'seven'
|
||||||
>>> C
|
>>> print C
|
||||||
Set-Cookie: number="I7\012.";
|
Set-Cookie: number="I7\012.";
|
||||||
Set-Cookie: string="S'seven'\012p1\012.";
|
Set-Cookie: string="S'seven'\012p1\012.";
|
||||||
>>> C = Cookie.SmartCookie()
|
>>> C = Cookie.SmartCookie()
|
||||||
|
|
@ -240,7 +242,7 @@ Set-Cookie: string="S'seven'\012p1\012.";
|
||||||
7
|
7
|
||||||
>>> C["string"].value
|
>>> C["string"].value
|
||||||
'seven'
|
'seven'
|
||||||
>>> C
|
>>> print C
|
||||||
Set-Cookie: number="I7\012.";
|
Set-Cookie: number="I7\012.";
|
||||||
Set-Cookie: string=seven;
|
Set-Cookie: string=seven;
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue