Package mapproxy :: Package core :: Module request :: Class NoCaseMultiDict
[hide private]
[frames] | no frames]

Class NoCaseMultiDict

source code

object --+    
         |    
      dict --+
             |
            NoCaseMultiDict

This is a dictionary that allows case insensitive access to values.

>>> d = NoCaseMultiDict([('A', 'b'), ('a', 'c'), ('B', 'f'), ('c', 'x'), ('c', 'y'), ('c', 'z')])
>>> d
NoCaseMultiDict([('A', ['b', 'c']), ('c', ['x', 'y', 'z']), ('B', ['f'])])
>>> d['a']
'b'
>>> d.get_all('a')
['b', 'c']
>>> 'a' in d and 'b' in d
True
Instance Methods [hide private]
new empty dictionary

__init__(self, mapping=())
A NoCaseMultiDict can be constructed from an iterable of (key, value) tuples or a dict.
source code
 
__getitem__(self, key)
Return the first data value for this key.
source code
 
__setitem__(self, key, value)
x[i]=y
source code
 
__delitem__(self, key)
del x[y]
source code
True if D has a key k, else False
__contains__(self, key) source code
 
__getstate__(self) source code
 
__setstate__(self, data) source code
D[k] if k in D, else d
get(self, key, default=None, type_func=None)
Return the default value if the requested data doesn't exist.
source code
 
get_all(self, key)
Return all values for the key as a list.
source code
 
set(self, key, value, append=False, unpack=False)
Set a value for the key.
source code
an iterator over the (key, value) items of D
iteritems(self)
Iterates over all keys and values.
source code
a shallow copy of D
copy(self)
Returns a copy of this object.
source code
 
__repr__(self)
repr(x)
source code

Inherited from dict: __cmp__, __eq__, __ge__, __getattribute__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __ne__, __new__, clear, fromkeys, has_key, items, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, mapping=())
(Constructor)

source code 
A NoCaseMultiDict can be constructed from an iterable of (key, value) tuples or a dict.
Returns:
new empty dictionary

Overrides: object.__init__

__getitem__(self, key)
(Indexing operator)

source code 
Return the first data value for this key.
Raises:
  • KeyError - if the key does not exist
Overrides: dict.__getitem__

__setitem__(self, key, value)
(Index assignment operator)

source code 
x[i]=y
Overrides: dict.__setitem__
(inherited documentation)

__delitem__(self, key)
(Index deletion operator)

source code 
del x[y]
Overrides: dict.__delitem__
(inherited documentation)

__contains__(self, key)
(In operator)

source code 
Returns: True if D has a key k, else False
Overrides: dict.__contains__
(inherited documentation)

get(self, key, default=None, type_func=None)

source code 

Return the default value if the requested data doesn't exist. If type_func is provided and is a callable it should convert the value, return it or raise a ValueError if that is not possible. In this case the function will return the default as if the value was not found.

Example:

>>> d = NoCaseMultiDict(dict(foo='42', bar='blub'))
>>> d.get('foo', type_func=int)
42
>>> d.get('bar', -1, type_func=int)
-1
Returns: D[k] if k in D, else d
Overrides: dict.get

get_all(self, key)

source code 
Return all values for the key as a list. Returns an empty list, if the key doesn't exist.

set(self, key, value, append=False, unpack=False)

source code 

Set a value for the key. If append is True the value will be added to other values for this key.

If unpack is True, value will be unpacked and each item will be added.

iteritems(self)

source code 
Iterates over all keys and values.
Returns: an iterator over the (key, value) items of D
Overrides: dict.iteritems

copy(self)

source code 
Returns a copy of this object.
Returns: a shallow copy of D
Overrides: dict.copy

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)