| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="morsel-objects.html" /> |
| 13 | <link rel="prev" href="module-Cookie.html" /> |
| 14 | <link rel="parent" href="module-Cookie.html" /> |
| 15 | <link rel="next" href="morsel-objects.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>11.21.1 Cookie Objects </title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="11.21 Cookie " |
| 25 | href="module-Cookie.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="11.21 Cookie " |
| 28 | href="module-Cookie.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="11.21.2 Morsel Objects" |
| 31 | href="morsel-objects.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-Cookie.html">11.21 Cookie </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="module-Cookie.html">11.21 Cookie </A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="morsel-objects.html">11.21.2 Morsel Objects</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H2><A NAME="SECTION00132110000000000000000"></A><A NAME="cookie-objects"></A> |
| 56 | <BR> |
| 57 | 11.21.1 Cookie Objects |
| 58 | </H2> |
| 59 | |
| 60 | <P> |
| 61 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 62 | <td><nobr><b><tt id='l2h-3683' xml:id='l2h-3683' class="method">value_decode</tt></b>(</nobr></td> |
| 63 | <td><var>val</var>)</td></tr></table></dt> |
| 64 | <dd> |
| 65 | Return a decoded value from a string representation. Return value can |
| 66 | be any type. This method does nothing in <tt class="class">BaseCookie</tt> -- it exists |
| 67 | so it can be overridden. |
| 68 | </dl> |
| 69 | |
| 70 | <P> |
| 71 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 72 | <td><nobr><b><tt id='l2h-3684' xml:id='l2h-3684' class="method">value_encode</tt></b>(</nobr></td> |
| 73 | <td><var>val</var>)</td></tr></table></dt> |
| 74 | <dd> |
| 75 | Return an encoded value. <var>val</var> can be any type, but return value |
| 76 | must be a string. This method does nothing in <tt class="class">BaseCookie</tt> -- it exists |
| 77 | so it can be overridden |
| 78 | |
| 79 | <P> |
| 80 | In general, it should be the case that <tt class="method">value_encode()</tt> and |
| 81 | <tt class="method">value_decode()</tt> are inverses on the range of <var>value_decode</var>. |
| 82 | </dl> |
| 83 | |
| 84 | <P> |
| 85 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 86 | <td><nobr><b><tt id='l2h-3685' xml:id='l2h-3685' class="method">output</tt></b>(</nobr></td> |
| 87 | <td><var></var><big>[</big><var>attrs</var><big>[</big><var>, header</var><big>[</big><var>, sep</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 88 | <dd> |
| 89 | Return a string representation suitable to be sent as HTTP headers. |
| 90 | <var>attrs</var> and <var>header</var> are sent to each <tt class="class">Morsel</tt>'s |
| 91 | <tt class="method">output()</tt> method. <var>sep</var> is used to join the headers |
| 92 | together, and is by default a newline. |
| 93 | </dl> |
| 94 | |
| 95 | <P> |
| 96 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 97 | <td><nobr><b><tt id='l2h-3686' xml:id='l2h-3686' class="method">js_output</tt></b>(</nobr></td> |
| 98 | <td><var></var><big>[</big><var>attrs</var><big>]</big><var></var>)</td></tr></table></dt> |
| 99 | <dd> |
| 100 | Return an embeddable JavaScript snippet, which, if run on a browser which |
| 101 | supports JavaScript, will act the same as if the HTTP headers was sent. |
| 102 | |
| 103 | <P> |
| 104 | The meaning for <var>attrs</var> is the same as in <tt class="method">output()</tt>. |
| 105 | </dl> |
| 106 | |
| 107 | <P> |
| 108 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 109 | <td><nobr><b><tt id='l2h-3687' xml:id='l2h-3687' class="method">load</tt></b>(</nobr></td> |
| 110 | <td><var>rawdata</var>)</td></tr></table></dt> |
| 111 | <dd> |
| 112 | If <var>rawdata</var> is a string, parse it as an <code>HTTP_COOKIE</code> and add |
| 113 | the values found there as <tt class="class">Morsel</tt>s. If it is a dictionary, it |
| 114 | is equivalent to: |
| 115 | |
| 116 | <P> |
| 117 | <div class="verbatim"><pre> |
| 118 | for k, v in rawdata.items(): |
| 119 | cookie[k] = v |
| 120 | </pre></div> |
| 121 | </dl> |
| 122 | |
| 123 | <P> |
| 124 | |
| 125 | <DIV CLASS="navigation"> |
| 126 | <div class='online-navigation'> |
| 127 | <p></p><hr /> |
| 128 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 129 | <tr> |
| 130 | <td class='online-navigation'><a rel="prev" title="11.21 Cookie " |
| 131 | href="module-Cookie.html"><img src='../icons/previous.png' |
| 132 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 133 | <td class='online-navigation'><a rel="parent" title="11.21 Cookie " |
| 134 | href="module-Cookie.html"><img src='../icons/up.png' |
| 135 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 136 | <td class='online-navigation'><a rel="next" title="11.21.2 Morsel Objects" |
| 137 | href="morsel-objects.html"><img src='../icons/next.png' |
| 138 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 139 | <td align="center" width="100%">Python Library Reference</td> |
| 140 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 141 | href="contents.html"><img src='../icons/contents.png' |
| 142 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 143 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 144 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 145 | <td class='online-navigation'><a rel="index" title="Index" |
| 146 | href="genindex.html"><img src='../icons/index.png' |
| 147 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 148 | </tr></table> |
| 149 | <div class='online-navigation'> |
| 150 | <b class="navlabel">Previous:</b> |
| 151 | <a class="sectref" rel="prev" href="module-Cookie.html">11.21 Cookie </A> |
| 152 | <b class="navlabel">Up:</b> |
| 153 | <a class="sectref" rel="parent" href="module-Cookie.html">11.21 Cookie </A> |
| 154 | <b class="navlabel">Next:</b> |
| 155 | <a class="sectref" rel="next" href="morsel-objects.html">11.21.2 Morsel Objects</A> |
| 156 | </div> |
| 157 | </div> |
| 158 | <hr /> |
| 159 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 160 | </DIV> |
| 161 | <!--End of Navigation Panel--> |
| 162 | <ADDRESS> |
| 163 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 164 | </ADDRESS> |
| 165 | </BODY> |
| 166 | </HTML> |