pyweblib.helper (version 0.3.0)
index
/usr/lib/python2.3/site-packages/pyweblib/helper.py

pyweblib.helper - Misc. stuff useful in CGI-BINs
(c) by Michael Stroeder <michael@stroeder.com>
 
This module is distributed under the terms of the
GPL (GNU GENERAL PUBLIC LICENSE) Version 2
(see http://www.gnu.org/copyleft/gpl.html)
 
$Id: pyweblib.helper.html,v 1.11 2004/03/31 19:30:47 michael Exp $

 
Modules
       
UserDict
os
re

 
Classes
       
UserDict.UserDict
AcceptHeaderDict
AcceptCharsetDict

 
class AcceptCharsetDict(AcceptHeaderDict)
    Special class for Accept-Charset header
 
 
Method resolution order:
AcceptCharsetDict
AcceptHeaderDict
UserDict.UserDict

Methods defined here:
__init__(self, envKey='HTTP_ACCEPT_CHARSET', env=None, defaultValue='utf-8')
preferred(self)
Return the value name with highest capability weigth

Methods inherited from AcceptHeaderDict:
__getitem__(self, value)
value
    String representing the value for which to return
    the floating point capability weight.
items(self)
Return the accepted values as tuples (value,weigth)
in descending order of capability weight
keys(self)
Return the accepted values in descending order of capability weight

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__contains__(self, key)
__delitem__(self, key)
__len__(self)
__repr__(self)
__setitem__(self, key, item)
clear(self)
copy(self)
get(self, key, failobj=None)
has_key(self, key)
iteritems(self)
iterkeys(self)
itervalues(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, failobj=None)
update(self, dict)
values(self)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

 
class AcceptHeaderDict(UserDict.UserDict)
    This dictionary class is used to parse
Accept-header lines with quality weights.
 
It's a base class for all Accept-* headers described
in sections 14.1 to 14.5 of RFC2616.
 
  Methods defined here:
__getitem__(self, value)
value
    String representing the value for which to return
    the floating point capability weight.
__init__(self, envKey, env=None, defaultValue=None)
Parse the Accept-* header line.
 
httpHeader
    string with value of Accept-* header line
items(self)
Return the accepted values as tuples (value,weigth)
in descending order of capability weight
keys(self)
Return the accepted values in descending order of capability weight

Methods inherited from UserDict.UserDict:
__cmp__(self, dict)
__contains__(self, key)
__delitem__(self, key)
__len__(self)
__repr__(self)
__setitem__(self, key, item)
clear(self)
copy(self)
get(self, key, failobj=None)
has_key(self, key)
iteritems(self)
iterkeys(self)
itervalues(self)
pop(self, key, *args)
popitem(self)
setdefault(self, key, failobj=None)
update(self, dict)
values(self)

Class methods inherited from UserDict.UserDict:
fromkeys(cls, iterable, value=None) from __builtin__.classobj

 
Functions
       
BrowserType(http_user_agent)
Parse the HTTP_USER_AGENT environment variable and return the
tuple (Browser,Version).
 
Not sure if this succeeds in every situation since most
browsers have very obscure HTTP_USER_AGENT entries for compability reasons.
The following browsers are known by name:
Netscape      Netscape Navigator, Netscape Communicator)
MSIE          MS Internet Explorer
Opera         Opera browser from http://www.operasoftware.com/
StarOffice    built-in browser of Star Office
Lynx          the text-based browser Lynx
NetPositive   Net Positive (BeOS)
guessClientAddr(env=None)
Guesses the host name or IP address of the HTTP client by looking
at various HTTP headers mapped to CGI-BIN environment.
 
env
      dictionary containing environment vars (default os.env)

 
Data
        __version__ = '0.3.0'
b = 'NetPositive'
compatible_browsers = ['Opera', 'StarOffice', 'Lynx', 'NCSA_Mosaic', 'MSIE', 'NetPositive']
compatible_browsers_re = <_sre.SRE_Pattern object>
known_browsers = {'Lynx': 'Lynx', 'MSIE': 'Microsoft Internet Explorer', 'Mozilla': 'Netscape Navigator', 'NCSA_Mosaic': 'NCSA Mosaic', 'NetPositive': 'Net Positive', 'Opera': 'Opera', 'StarOffice': 'StarOffice'}
known_browsers_rev = {'Lynx': 'Lynx', 'Microsoft Internet Explorer': 'MSIE', 'NCSA Mosaic': 'NCSA_Mosaic', 'Net Positive': 'NetPositive', 'Netscape Navigator': 'Mozilla', 'Opera': 'Opera', 'StarOffice': 'StarOffice'}
mozilla_re = <_sre.SRE_Pattern object>