Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
MoinMoin.support.werkzeug.datastructures.MIMEAccept Class Reference
Inheritance diagram for MoinMoin.support.werkzeug.datastructures.MIMEAccept:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.werkzeug.datastructures.MIMEAccept:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def accept_html
def accept_xhtml
def __getitem__
def __contains__
def __repr__
def index
def find
def values
def itervalues
def to_header
def __str__
def best
def __delitem__
def __delslice__
def __iadd__
def __setitem__
def __setslice__
def append
def extend
def insert
def pop
def reverse
def sort

Public Attributes

 provided

Static Public Attributes

 remove = append

Private Member Functions

def _value_matches

Detailed Description

Like :class:`Accept` but with special methods and behavior for
mimetypes.

Definition at line 1261 of file datastructures.py.


Member Function Documentation

def MoinMoin.support.werkzeug.datastructures.Accept.__contains__ (   self,
  value 
) [inherited]

Definition at line 1195 of file datastructures.py.

01195 
01196     def __contains__(self, value):
01197         for item, quality in self:
01198             if self._value_matches(value, item):
01199                 return True
01200         return False

Here is the call graph for this function:

Definition at line 32 of file datastructures.py.

00032 
00033     def __delitem__(self, key):
00034         is_immutable(self)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 35 of file datastructures.py.

00035 
00036     def __delslice__(self, i, j):
00037         is_immutable(self)

Here is the call graph for this function:

def MoinMoin.support.werkzeug.datastructures.Accept.__getitem__ (   self,
  key 
) [inherited]
Besides index lookup (getting item n) you can also pass it a string
to get the quality for the item.  If the item is not in the list, the
returned quality is ``0``.

Definition at line 1183 of file datastructures.py.

01183 
01184     def __getitem__(self, key):
01185         """Besides index lookup (getting item n) you can also pass it a string
01186         to get the quality for the item.  If the item is not in the list, the
01187         returned quality is ``0``.
01188         """
01189         if isinstance(key, basestring):
01190             for item, quality in self:
01191                 if self._value_matches(key, item):
01192                     return quality
01193             return 0
01194         return list.__getitem__(self, key)

Here is the call graph for this function:

Definition at line 38 of file datastructures.py.

00038 
00039     def __iadd__(self, other):
        is_immutable(self)

Here is the call graph for this function:

Definition at line 1201 of file datastructures.py.

01201 
01202     def __repr__(self):
01203         return '%s([%s])' % (
01204             self.__class__.__name__,
01205             ', '.join('(%r, %s)' % (x, y) for x, y in self)
01206         )

def MoinMoin.support.werkzeug.datastructures.ImmutableListMixin.__setitem__ (   self,
  key,
  value 
) [inherited]

Definition at line 42 of file datastructures.py.

00042 
00043     def __setitem__(self, key, value):
00044         is_immutable(self)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.support.werkzeug.datastructures.ImmutableListMixin.__setslice__ (   self,
  i,
  j,
  value 
) [inherited]

Definition at line 45 of file datastructures.py.

00045 
00046     def __setslice__(self, i, j, value):
00047         is_immutable(self)

Here is the call graph for this function:

Definition at line 1251 of file datastructures.py.

01251 
01252     def __str__(self):
01253         return self.to_header()

Here is the call graph for this function:

def MoinMoin.support.werkzeug.datastructures.MIMEAccept._value_matches (   self,
  value,
  item 
) [private]
Check if a value matches a given accept item.

Reimplemented from MoinMoin.support.werkzeug.datastructures.Accept.

Definition at line 1266 of file datastructures.py.

01266 
01267     def _value_matches(self, value, item):
01268         def _normalize(x):
01269             x = x.lower()
01270             return x == '*' and ('*', '*') or x.split('/', 1)
01271 
01272         # this is from the application which is trusted.  to avoid developer
01273         # frustration we actually check these for valid values
01274         if '/' not in value:
01275             raise ValueError('invalid mimetype %r' % value)
01276         value_type, value_subtype = _normalize(value)
01277         if value_type == '*' and value_subtype != '*':
01278             raise ValueError('invalid mimetype %r' % value)
01279 
01280         if '/' not in item:
01281             return False
01282         item_type, item_subtype = _normalize(item)
01283         if item_type == '*' and item_subtype != '*':
01284             return False
01285         return (
01286             (item_type == item_subtype == '*' or
01287              value_type == value_subtype == '*') or
01288             (item_type == value_type and (item_subtype == '*' or
01289                                           value_subtype == '*' or
01290                                           item_subtype == value_subtype))
01291         )

True if this object accepts HTML.

Definition at line 1293 of file datastructures.py.

01293 
01294     def accept_html(self):
01295         """True if this object accepts HTML."""
01296         return (
01297             'text/html' in self or
01298             'application/xhtml+xml' in self or
01299             self.accept_xhtml
01300         )

Here is the call graph for this function:

True if this object accepts XHTML.

Definition at line 1302 of file datastructures.py.

01302 
01303     def accept_xhtml(self):
01304         """True if this object accepts XHTML."""
01305         return (
01306             'application/xhtml+xml' in self or
01307             'application/xml' in self
01308         )
01309 

Here is the caller graph for this function:

Definition at line 48 of file datastructures.py.

00048 
00049     def append(self, item):
        is_immutable(self)

Here is the call graph for this function:

Here is the caller graph for this function:

The best match as value.

Definition at line 1255 of file datastructures.py.

01255 
01256     def best(self):
01257         """The best match as value."""
01258         if self:
01259             return self[0][0]
01260 

def MoinMoin.support.werkzeug.datastructures.ImmutableListMixin.extend (   self,
  iterable 
) [inherited]

Definition at line 52 of file datastructures.py.

00052 
00053     def extend(self, iterable):
00054         is_immutable(self)

Here is the call graph for this function:

def MoinMoin.support.werkzeug.datastructures.Accept.find (   self,
  key 
) [inherited]
Get the position of an entry or return -1.

:param key: The key to be looked up.

Definition at line 1223 of file datastructures.py.

01223 
01224     def find(self, key):
01225         """Get the position of an entry or return -1.
01226 
01227         :param key: The key to be looked up.
01228         """
01229         try:
01230             return self.index(key)
01231         except ValueError:
01232             return -1

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.support.werkzeug.datastructures.Accept.index (   self,
  key 
) [inherited]
Get the position of an entry or raise :exc:`ValueError`.

:param key: The key to be looked up.

.. versionchanged:: 0.5
   This used to raise :exc:`IndexError`, which was inconsistent
   with the list API.

Definition at line 1207 of file datastructures.py.

01207 
01208     def index(self, key):
01209         """Get the position of an entry or raise :exc:`ValueError`.
01210 
01211         :param key: The key to be looked up.
01212 
01213         .. versionchanged:: 0.5
01214            This used to raise :exc:`IndexError`, which was inconsistent
01215            with the list API.
01216         """
01217         if isinstance(key, basestring):
01218             for idx, (item, quality) in enumerate(self):
01219                 if self._value_matches(key, item):
01220                     return idx
01221             raise ValueError(key)
01222         return list.index(self, key)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.support.werkzeug.datastructures.ImmutableListMixin.insert (   self,
  pos,
  value 
) [inherited]

Definition at line 55 of file datastructures.py.

00055 
00056     def insert(self, pos, value):
00057         is_immutable(self)

Here is the call graph for this function:

Iterate over all values.

Definition at line 1237 of file datastructures.py.

01237 
01238     def itervalues(self):
01239         """Iterate over all values."""
01240         for item in self:
01241             yield item[0]

Here is the caller graph for this function:

def MoinMoin.support.werkzeug.datastructures.ImmutableListMixin.pop (   self,
  index = -1 
) [inherited]

Definition at line 58 of file datastructures.py.

00058 
00059     def pop(self, index=-1):
00060         is_immutable(self)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 61 of file datastructures.py.

00061 
00062     def reverse(self):
00063         is_immutable(self)

Here is the call graph for this function:

def MoinMoin.support.werkzeug.datastructures.ImmutableListMixin.sort (   self,
  cmp = None,
  key = None,
  reverse = None 
) [inherited]

Definition at line 64 of file datastructures.py.

00064 
00065     def sort(self, cmp=None, key=None, reverse=None):
00066         is_immutable(self)
00067 

Here is the call graph for this function:

Convert the header set into an HTTP header string.

Definition at line 1242 of file datastructures.py.

01242 
01243     def to_header(self):
01244         """Convert the header set into an HTTP header string."""
01245         result = []
01246         for value, quality in self:
01247             if quality != 1:
01248                 value = '%s;q=%s' % (value, quality)
01249             result.append(value)
01250         return ','.join(result)

Here is the caller graph for this function:

Return a list of the values, not the qualities.

Definition at line 1233 of file datastructures.py.

01233 
01234     def values(self):
01235         """Return a list of the values, not the qualities."""
01236         return list(self.itervalues())

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1168 of file datastructures.py.

Definition at line 50 of file datastructures.py.


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