1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module pyweblib.helper</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="pyweblib.html"><font color="#ffffff">pyweblib</font></a>.helper</strong></big></big> (version 0.3.0)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/lib/python2.3/site-packages/pyweblib/helper.py">/usr/lib/python2.3/site-packages/pyweblib/helper.py</a></font></td></tr></table>
<p><tt>pyweblib.helper - Misc. stuff useful in CGI-BINs<br>
(c) by Michael Stroeder <michael@stroeder.com><br>
<br>
This module is distributed under the terms of the<br>
GPL (GNU GENERAL PUBLIC LICENSE) Version 2<br>
(see <a href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a>)<br>
<br>
$Id: pyweblib.helper.html,v 1.12 2004/08/24 10:26:30 michael Exp $</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="UserDict.html">UserDict</a><br>
</td><td width="25%" valign=top><a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="re.html">re</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="UserDict.html#UserDict">UserDict.UserDict</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="pyweblib.helper.html#AcceptHeaderDict">AcceptHeaderDict</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="pyweblib.helper.html#AcceptCharsetDict">AcceptCharsetDict</a>
</font></dt></dl>
</dd>
</dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AcceptCharsetDict">class <strong>AcceptCharsetDict</strong></a>(<a href="pyweblib.helper.html#AcceptHeaderDict">AcceptHeaderDict</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Special class for Accept-Charset header<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="pyweblib.helper.html#AcceptCharsetDict">AcceptCharsetDict</a></dd>
<dd><a href="pyweblib.helper.html#AcceptHeaderDict">AcceptHeaderDict</a></dd>
<dd><a href="UserDict.html#UserDict">UserDict.UserDict</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="AcceptCharsetDict-__init__"><strong>__init__</strong></a>(self, envKey<font color="#909090">='HTTP_ACCEPT_CHARSET'</font>, env<font color="#909090">=None</font>, defaultValue<font color="#909090">='utf-8'</font>)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-preferred"><strong>preferred</strong></a>(self)</dt><dd><tt>Return the value name with highest capability weigth</tt></dd></dl>
<hr>
Methods inherited from <a href="pyweblib.helper.html#AcceptHeaderDict">AcceptHeaderDict</a>:<br>
<dl><dt><a name="AcceptCharsetDict-__getitem__"><strong>__getitem__</strong></a>(self, value)</dt><dd><tt>value<br>
String representing the value for which to return<br>
the floating point capability weight.</tt></dd></dl>
<dl><dt><a name="AcceptCharsetDict-items"><strong>items</strong></a>(self)</dt><dd><tt>Return the accepted values as tuples (value,weigth)<br>
in descending order of capability weight</tt></dd></dl>
<dl><dt><a name="AcceptCharsetDict-keys"><strong>keys</strong></a>(self)</dt><dd><tt>Return the accepted values in descending order of capability weight</tt></dd></dl>
<hr>
Methods inherited from <a href="UserDict.html#UserDict">UserDict.UserDict</a>:<br>
<dl><dt><a name="AcceptCharsetDict-__cmp__"><strong>__cmp__</strong></a>(self, dict)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-__contains__"><strong>__contains__</strong></a>(self, key)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-__delitem__"><strong>__delitem__</strong></a>(self, key)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-__len__"><strong>__len__</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-__setitem__"><strong>__setitem__</strong></a>(self, key, item)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-clear"><strong>clear</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-copy"><strong>copy</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-get"><strong>get</strong></a>(self, key, failobj<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-has_key"><strong>has_key</strong></a>(self, key)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-iteritems"><strong>iteritems</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-iterkeys"><strong>iterkeys</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-itervalues"><strong>itervalues</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-pop"><strong>pop</strong></a>(self, key, *args)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-popitem"><strong>popitem</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-setdefault"><strong>setdefault</strong></a>(self, key, failobj<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-update"><strong>update</strong></a>(self, dict)</dt></dl>
<dl><dt><a name="AcceptCharsetDict-values"><strong>values</strong></a>(self)</dt></dl>
<hr>
Class methods inherited from <a href="UserDict.html#UserDict">UserDict.UserDict</a>:<br>
<dl><dt><a name="AcceptCharsetDict-fromkeys"><strong>fromkeys</strong></a>(cls, iterable, value<font color="#909090">=None</font>)<font color="#909090"><font face="helvetica, arial"> from __builtin__.classobj</font></font></dt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AcceptHeaderDict">class <strong>AcceptHeaderDict</strong></a>(<a href="UserDict.html#UserDict">UserDict.UserDict</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>This dictionary class is used to parse<br>
Accept-header lines with quality weights.<br>
<br>
It's a base class for all Accept-* headers described<br>
in sections 14.1 to 14.5 of <a href="http://www.rfc-editor.org/rfc/rfc2616.txt">RFC2616</a>.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="AcceptHeaderDict-__getitem__"><strong>__getitem__</strong></a>(self, value)</dt><dd><tt>value<br>
String representing the value for which to return<br>
the floating point capability weight.</tt></dd></dl>
<dl><dt><a name="AcceptHeaderDict-__init__"><strong>__init__</strong></a>(self, envKey, env<font color="#909090">=None</font>, defaultValue<font color="#909090">=None</font>)</dt><dd><tt>Parse the Accept-* header line.<br>
<br>
httpHeader<br>
string with value of Accept-* header line</tt></dd></dl>
<dl><dt><a name="AcceptHeaderDict-items"><strong>items</strong></a>(self)</dt><dd><tt>Return the accepted values as tuples (value,weigth)<br>
in descending order of capability weight</tt></dd></dl>
<dl><dt><a name="AcceptHeaderDict-keys"><strong>keys</strong></a>(self)</dt><dd><tt>Return the accepted values in descending order of capability weight</tt></dd></dl>
<hr>
Methods inherited from <a href="UserDict.html#UserDict">UserDict.UserDict</a>:<br>
<dl><dt><a name="AcceptHeaderDict-__cmp__"><strong>__cmp__</strong></a>(self, dict)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-__contains__"><strong>__contains__</strong></a>(self, key)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-__delitem__"><strong>__delitem__</strong></a>(self, key)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-__len__"><strong>__len__</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-__setitem__"><strong>__setitem__</strong></a>(self, key, item)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-clear"><strong>clear</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-copy"><strong>copy</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-get"><strong>get</strong></a>(self, key, failobj<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-has_key"><strong>has_key</strong></a>(self, key)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-iteritems"><strong>iteritems</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-iterkeys"><strong>iterkeys</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-itervalues"><strong>itervalues</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-pop"><strong>pop</strong></a>(self, key, *args)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-popitem"><strong>popitem</strong></a>(self)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-setdefault"><strong>setdefault</strong></a>(self, key, failobj<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-update"><strong>update</strong></a>(self, dict)</dt></dl>
<dl><dt><a name="AcceptHeaderDict-values"><strong>values</strong></a>(self)</dt></dl>
<hr>
Class methods inherited from <a href="UserDict.html#UserDict">UserDict.UserDict</a>:<br>
<dl><dt><a name="AcceptHeaderDict-fromkeys"><strong>fromkeys</strong></a>(cls, iterable, value<font color="#909090">=None</font>)<font color="#909090"><font face="helvetica, arial"> from __builtin__.classobj</font></font></dt></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-BrowserType"><strong>BrowserType</strong></a>(http_user_agent)</dt><dd><tt>Parse the HTTP_USER_AGENT environment variable and return the<br>
tuple (Browser,Version).<br>
<br>
Not sure if this succeeds in every situation since most<br>
browsers have very obscure HTTP_USER_AGENT entries for compability reasons.<br>
The following browsers are known by name:<br>
Netscape Netscape Navigator, Netscape Communicator)<br>
MSIE MS Internet Explorer<br>
Opera Opera browser from <a href="http://www.operasoftware.com/">http://www.operasoftware.com/</a><br>
StarOffice built-in browser of Star Office<br>
Lynx the text-based browser Lynx<br>
NetPositive Net Positive (BeOS)</tt></dd></dl>
<dl><dt><a name="-guessClientAddr"><strong>guessClientAddr</strong></a>(env<font color="#909090">=None</font>)</dt><dd><tt>Guesses the host name or IP address of the HTTP client by looking<br>
at various HTTP headers mapped to CGI-BIN environment.<br>
<br>
env<br>
dictionary containing environment vars (default os.env)</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>__version__</strong> = '0.3.0'<br>
<strong>b</strong> = 'NetPositive'<br>
<strong>compatible_browsers</strong> = ['Opera', 'StarOffice', 'Lynx', 'NCSA_Mosaic', 'MSIE', 'NetPositive']<br>
<strong>compatible_browsers_re</strong> = <_sre.SRE_Pattern object><br>
<strong>known_browsers</strong> = {'Lynx': 'Lynx', 'MSIE': 'Microsoft Internet Explorer', 'Mozilla': 'Netscape Navigator', 'NCSA_Mosaic': 'NCSA Mosaic', 'NetPositive': 'Net Positive', 'Opera': 'Opera', 'StarOffice': 'StarOffice'}<br>
<strong>known_browsers_rev</strong> = {'Lynx': 'Lynx', 'Microsoft Internet Explorer': 'MSIE', 'NCSA Mosaic': 'NCSA_Mosaic', 'Net Positive': 'NetPositive', 'Netscape Navigator': 'Mozilla', 'Opera': 'Opera', 'StarOffice': 'StarOffice'}<br>
<strong>mozilla_re</strong> = <_sre.SRE_Pattern object></td></tr></table>
</body></html>
|