| 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="cookie-example.html" /> |
| 13 | <link rel="prev" href="cookie-objects.html" /> |
| 14 | <link rel="parent" href="module-Cookie.html" /> |
| 15 | <link rel="next" href="cookie-example.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>11.21.2 Morsel 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.1 Cookie Objects" |
| 25 | href="cookie-objects.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.3 Example" |
| 31 | href="cookie-example.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="cookie-objects.html">11.21.1 Cookie Objects</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="cookie-example.html">11.21.3 Example</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H2><A NAME="SECTION00132120000000000000000"></A><A NAME="morsel-objects"></A> |
| 56 | <BR> |
| 57 | 11.21.2 Morsel Objects |
| 58 | </H2> |
| 59 | |
| 60 | <P> |
| 61 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 62 | <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-3688' xml:id='l2h-3688' class="class">Morsel</tt></b>(</nobr></td> |
| 63 | <td><var></var>)</td></tr></table></dt> |
| 64 | <dd> |
| 65 | Abstract a key/value pair, which has some <a class="rfc" id='rfcref-90583' xml:id='rfcref-90583' |
| 66 | href="http://www.faqs.org/rfcs/rfc2109.html">RFC 2109</a> attributes. |
| 67 | |
| 68 | <P> |
| 69 | Morsels are dictionary-like objects, whose set of keys is constant -- |
| 70 | the valid <a class="rfc" id='rfcref-90585' xml:id='rfcref-90585' |
| 71 | href="http://www.faqs.org/rfcs/rfc2109.html">RFC 2109</a> attributes, which are |
| 72 | |
| 73 | <P> |
| 74 | |
| 75 | <UL> |
| 76 | <LI><code>expires</code> |
| 77 | </LI> |
| 78 | <LI><code>path</code> |
| 79 | </LI> |
| 80 | <LI><code>comment</code> |
| 81 | </LI> |
| 82 | <LI><code>domain</code> |
| 83 | </LI> |
| 84 | <LI><code>max-age</code> |
| 85 | </LI> |
| 86 | <LI><code>secure</code> |
| 87 | </LI> |
| 88 | <LI><code>version</code> |
| 89 | </LI> |
| 90 | </UL> |
| 91 | |
| 92 | <P> |
| 93 | The keys are case-insensitive. |
| 94 | </dl> |
| 95 | |
| 96 | <P> |
| 97 | <dl><dt><b><tt id='l2h-3689' xml:id='l2h-3689' class="member">value</tt></b></dt> |
| 98 | <dd> |
| 99 | The value of the cookie. |
| 100 | </dl> |
| 101 | |
| 102 | <P> |
| 103 | <dl><dt><b><tt id='l2h-3690' xml:id='l2h-3690' class="member">coded_value</tt></b></dt> |
| 104 | <dd> |
| 105 | The encoded value of the cookie -- this is what should be sent. |
| 106 | </dl> |
| 107 | |
| 108 | <P> |
| 109 | <dl><dt><b><tt id='l2h-3691' xml:id='l2h-3691' class="member">key</tt></b></dt> |
| 110 | <dd> |
| 111 | The name of the cookie. |
| 112 | </dl> |
| 113 | |
| 114 | <P> |
| 115 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 116 | <td><nobr><b><tt id='l2h-3692' xml:id='l2h-3692' class="method">set</tt></b>(</nobr></td> |
| 117 | <td><var>key, value, coded_value</var>)</td></tr></table></dt> |
| 118 | <dd> |
| 119 | Set the <var>key</var>, <var>value</var> and <var>coded_value</var> members. |
| 120 | </dl> |
| 121 | |
| 122 | <P> |
| 123 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 124 | <td><nobr><b><tt id='l2h-3693' xml:id='l2h-3693' class="method">isReservedKey</tt></b>(</nobr></td> |
| 125 | <td><var>K</var>)</td></tr></table></dt> |
| 126 | <dd> |
| 127 | Whether <var>K</var> is a member of the set of keys of a <tt class="class">Morsel</tt>. |
| 128 | </dl> |
| 129 | |
| 130 | <P> |
| 131 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 132 | <td><nobr><b><tt id='l2h-3694' xml:id='l2h-3694' class="method">output</tt></b>(</nobr></td> |
| 133 | <td><var></var><big>[</big><var>attrs</var><big>[</big><var>, header</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 134 | <dd> |
| 135 | Return a string representation of the Morsel, suitable |
| 136 | to be sent as an HTTP header. By default, all the attributes are included, |
| 137 | unless <var>attrs</var> is given, in which case it should be a list of attributes |
| 138 | to use. <var>header</var> is by default <code>"Set-Cookie:"</code>. |
| 139 | </dl> |
| 140 | |
| 141 | <P> |
| 142 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 143 | <td><nobr><b><tt id='l2h-3695' xml:id='l2h-3695' class="method">js_output</tt></b>(</nobr></td> |
| 144 | <td><var></var><big>[</big><var>attrs</var><big>]</big><var></var>)</td></tr></table></dt> |
| 145 | <dd> |
| 146 | Return an embeddable JavaScript snippet, which, if run on a browser which |
| 147 | supports JavaScript, will act the same as if the HTTP header was sent. |
| 148 | |
| 149 | <P> |
| 150 | The meaning for <var>attrs</var> is the same as in <tt class="method">output()</tt>. |
| 151 | </dl> |
| 152 | |
| 153 | <P> |
| 154 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 155 | <td><nobr><b><tt id='l2h-3696' xml:id='l2h-3696' class="method">OutputString</tt></b>(</nobr></td> |
| 156 | <td><var></var><big>[</big><var>attrs</var><big>]</big><var></var>)</td></tr></table></dt> |
| 157 | <dd> |
| 158 | Return a string representing the Morsel, without any surrounding HTTP |
| 159 | or JavaScript. |
| 160 | |
| 161 | <P> |
| 162 | The meaning for <var>attrs</var> is the same as in <tt class="method">output()</tt>. |
| 163 | </dl> |
| 164 | |
| 165 | <P> |
| 166 | |
| 167 | <DIV CLASS="navigation"> |
| 168 | <div class='online-navigation'> |
| 169 | <p></p><hr /> |
| 170 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 171 | <tr> |
| 172 | <td class='online-navigation'><a rel="prev" title="11.21.1 Cookie Objects" |
| 173 | href="cookie-objects.html"><img src='../icons/previous.png' |
| 174 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 175 | <td class='online-navigation'><a rel="parent" title="11.21 Cookie " |
| 176 | href="module-Cookie.html"><img src='../icons/up.png' |
| 177 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 178 | <td class='online-navigation'><a rel="next" title="11.21.3 Example" |
| 179 | href="cookie-example.html"><img src='../icons/next.png' |
| 180 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 181 | <td align="center" width="100%">Python Library Reference</td> |
| 182 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 183 | href="contents.html"><img src='../icons/contents.png' |
| 184 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 185 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 186 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 187 | <td class='online-navigation'><a rel="index" title="Index" |
| 188 | href="genindex.html"><img src='../icons/index.png' |
| 189 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 190 | </tr></table> |
| 191 | <div class='online-navigation'> |
| 192 | <b class="navlabel">Previous:</b> |
| 193 | <a class="sectref" rel="prev" href="cookie-objects.html">11.21.1 Cookie Objects</A> |
| 194 | <b class="navlabel">Up:</b> |
| 195 | <a class="sectref" rel="parent" href="module-Cookie.html">11.21 Cookie </A> |
| 196 | <b class="navlabel">Next:</b> |
| 197 | <a class="sectref" rel="next" href="cookie-example.html">11.21.3 Example</A> |
| 198 | </div> |
| 199 | </div> |
| 200 | <hr /> |
| 201 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 202 | </DIV> |
| 203 | <!--End of Navigation Panel--> |
| 204 | <ADDRESS> |
| 205 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 206 | </ADDRESS> |
| 207 | </BODY> |
| 208 | </HTML> |