Fix the example (it didn't seem to reflect reality).

This commit is contained in:
Ka-Ping Yee 2001-01-18 07:50:17 +00:00
parent 6f477a6c07
commit 3a9582fbe5
1 changed files with 14 additions and 12 deletions

View File

@ -173,19 +173,21 @@ The meaning for \var{attrs} is the same as in \method{output()}.
\subsection{Example \label{cookie-example}}
The following example demonstrates how to open a can of spam using the
\module{spam} module.
The following example demonstrates how to use the \module{Cookie} module.
\begin{verbatim}
>>> import Cookie
>>> C = Cookie.SimpleCookie()
>>> C = Cookie.SerialCookie()
>>> C = Cookie.SmartCookie()
>>> C = Cookie.Cookie() # backwards compatible alias for SmartCookie
>>> C = Cookie.Cookie() # backwards-compatible alias for SmartCookie
>>> C = Cookie.SmartCookie()
>>> C["fig"] = "newton"
>>> 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: fig=newton;
>>> C = Cookie.SmartCookie()
@ -197,18 +199,18 @@ Cookie: rocky=road; Path=/cookie;
Cookie: rocky=road;
>>> C = Cookie.SmartCookie()
>>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
>>> C
>>> print C
Set-Cookie: vienna=finger;
Set-Cookie: chips=ahoy;
>>> C = Cookie.SmartCookie()
>>> C.load('keebler="E=everybody; L=\"Loves\"; fudge=\012;";')
>>> C
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
>>> print C
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;";
>>> C = Cookie.SmartCookie()
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
>>> C
Set-Cookie: oreo="doublestuff"; Path=/;
>>> print C
Set-Cookie: oreo=doublestuff; Path=/;
>>> C = Cookie.SmartCookie()
>>> C["twix"] = "none for you"
>>> C["twix"].value
@ -220,7 +222,7 @@ Set-Cookie: oreo="doublestuff"; Path=/;
'7'
>>> C["string"].value
'seven'
>>> C
>>> print C
Set-Cookie: number=7;
Set-Cookie: string=seven;
>>> C = Cookie.SerialCookie()
@ -230,7 +232,7 @@ Set-Cookie: string=seven;
7
>>> C["string"].value
'seven'
>>> C
>>> print C
Set-Cookie: number="I7\012.";
Set-Cookie: string="S'seven'\012p1\012.";
>>> C = Cookie.SmartCookie()
@ -240,7 +242,7 @@ Set-Cookie: string="S'seven'\012p1\012.";
7
>>> C["string"].value
'seven'
>>> C
>>> print C
Set-Cookie: number="I7\012.";
Set-Cookie: string=seven;
\end{verbatim}