webob.multidict – multi-value dictionary object

Gives a multi-value dictionary object (MultiDict) plus several wrappers

class webob.multidict.MultiDict(*args, **kw)

An ordered dictionary that can have multiple values for each key. Adds the methods getall, getone, mixed and extend and add to the normal dictionary interface.

add(key, value)

Add the key and value, not overwriting any previous value.

clear() → None. Remove all items from D.
dict_of_lists()

Returns a dictionary where each key is associated with a list of values.

classmethod from_fieldstorage(fs)

Create a dict from a cgi.FieldStorage instance

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
getall(key)

Return a list of all values matching the key (may be an empty list)

getone(key)

Get one value matching the key, raising a KeyError if multiple values were found.

mixed()

Returns a dictionary where the values are either single values, or a list of values when a key/value appears more than once in this dictionary. This is similar to the kind of dictionary often used to represent the variables in a web request.

pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

classmethod view_list(lst)

Create a dict that is a view on the given list

class webob.multidict.NestedMultiDict(*dicts)

Wraps several MultiDict objects, treating it as one large MultiDict

getall(key)

Return a list of all values matching the key (may be an empty list)

class webob.multidict.NoVars(reason=None)

Represents no variables; used when no variables are applicable.

This is read-only