Back to index

python-weblib  1.3.9
Public Member Functions | Public Attributes
pyweblib.helper.AcceptCharsetDict Class Reference
Inheritance diagram for pyweblib.helper.AcceptCharsetDict:
Inheritance graph
[legend]
Collaboration diagram for pyweblib.helper.AcceptCharsetDict:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def preferred
def __getitem__
def items
def keys

Public Attributes

 defaultValue
 preferred_value
 data

Detailed Description

Special class for Accept-Charset header

Definition at line 161 of file helper.py.


Constructor & Destructor Documentation

def pyweblib.helper.AcceptCharsetDict.__init__ (   self,
  envKey = 'HTTP_ACCEPT_CHARSET',
  env = None,
  defaultValue = 'utf-8' 
)
Parse the Accept-* header line.

httpHeader
string with value of Accept-* header line

Reimplemented from pyweblib.helper.AcceptHeaderDict.

Definition at line 166 of file helper.py.

00166 
00167   def __init__(self,envKey='HTTP_ACCEPT_CHARSET',env=None,defaultValue='utf-8'):
00168     AcceptHeaderDict.__init__(self,envKey,env,defaultValue)
00169     # Special treating of ISO-8859-1 charset to be compliant to RFC2616
00170     self.data['iso-8859-1'] = self.data.get('iso-8859-1',self.data.get('*',1.0))
00171     return # AcceptCharsetDict.__init__()


Member Function Documentation

def pyweblib.helper.AcceptHeaderDict.__getitem__ (   self,
  value 
) [inherited]
value
String representing the value for which to return
the floating point capability weight.

Definition at line 133 of file helper.py.

00133 
00134   def __getitem__(self,value):
00135     """
00136     value
00137         String representing the value for which to return
00138         the floating point capability weight.
00139     """
00140     return self.data.get(
00141       value.lower(),
00142       self.data.get('*',0)
00143     )

def pyweblib.helper.AcceptHeaderDict.items (   self) [inherited]
Return the accepted values as tuples (value,weigth)
in descending order of capability weight

Definition at line 144 of file helper.py.

00144 
00145   def items(self):
00146     """
00147     Return the accepted values as tuples (value,weigth)
00148     in descending order of capability weight
00149     """
00150     l = self.data.items()
00151     l.sort(lambda x,y:cmp(y[1],x[1]))
00152     return l

Here is the caller graph for this function:

def pyweblib.helper.AcceptHeaderDict.keys (   self) [inherited]
Return the accepted values in descending order of capability weight

Definition at line 153 of file helper.py.

00153 
00154   def keys(self):
00155     """
00156     Return the accepted values in descending order of capability weight
00157     """
00158     l = self.items()
00159     return [ k for k,v in l ]
00160 

Here is the call graph for this function:

Return the value name with highest capability weigth

Definition at line 172 of file helper.py.

00172 
00173   def preferred(self):
00174     """
00175     Return the value name with highest capability weigth
00176     """
00177     l = self.items()
00178     while l and l[0][0]!='*':
00179       try:
00180         u''.encode(l[0][0])
00181       except LookupError:
00182         l.pop(0)
00183       else:
00184         break
00185     if l:
00186       if self.defaultValue and l[0][0]=='*':
00187         return self.defaultValue
00188       else:
00189         return l[0][0]
00190     else:
00191       return self.defaultValue
00192 

Here is the call graph for this function:


Member Data Documentation

Definition at line 110 of file helper.py.

Definition at line 101 of file helper.py.

Definition at line 102 of file helper.py.


The documentation for this class was generated from the following file: