class documentation

class FileMultiDict(MultiDict): (source)

View In Hierarchy

A special :class:`MultiDict` that has convenience methods to add files to it. This is used for :class:`EnvironBuilder` and generally useful for unittesting. .. versionadded:: 0.5

Method add_file Adds a new file to the dict. `file` can be a file name or a :class:`file`-like or a :class:`FileStorage` object.

Inherited from MultiDict:

Method __copy__ Undocumented
Method __deepcopy__ Undocumented
Method __getitem__ Return the first data value for this key; raises KeyError if not found.
Method __getstate__ Undocumented
Method __init__ Undocumented
Method __iter__ Undocumented
Method __repr__ Undocumented
Method __setitem__ Like :meth:`add` but removes an existing key first.
Method __setstate__ Undocumented
Method add Adds a new value for the key.
Method copy Return a shallow copy of this object.
Method deepcopy Return a deep copy of this object.
Method getlist Return the list of items for a given key. If that key is not in the `MultiDict`, the return value will be an empty list. Just like `get`, `getlist` accepts a `type` parameter. All items will be converted with the callable defined there.
Method items Return an iterator of ``(key, value)`` pairs.
Method lists Return a iterator of ``(key, values)`` pairs, where values is the list of all values associated with the key.
Method listvalues Return an iterator of all values associated with a key. Zipping :meth:`keys` and this is the same as calling :meth:`lists`:
Method pop Pop the first item for a list on the dict. Afterwards the key is removed from the dict, so additional values are discarded:
Method popitem Pop an item from the dict.
Method popitemlist Pop a ``(key, list)`` tuple from the dict.
Method poplist Pop the list for a key from the dict. If the key is not in the dict an empty list is returned.
Method setdefault Returns the value for the key if it is in the dict, otherwise it returns `default` and sets that value for `key`.
Method setlist Remove the old values for a key and add new ones. Note that the list you pass the values in will be shallow-copied before it is inserted in the dictionary.
Method setlistdefault Like `setdefault` but sets multiple values. The list returned is not a copy, but the list that is actually used internally. This means that you can put new values into the dict by appending items to the list:...
Method to_dict Return the contents as regular dict. If `flat` is `True` the returned dict will only have the first item present, if `flat` is `False` all values will be returned as lists.
Method update update() extends rather than replaces existing key lists:
Method values Returns an iterator of the first value on every key's value list.

Inherited from TypeConversionDict (via MultiDict):

Method get Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the default as if the value was not found:...
def add_file(self, name, file, filename=None, content_type=None): (source)

Adds a new file to the dict. `file` can be a file name or a :class:`file`-like or a :class:`FileStorage` object. :param name: the name of the field. :param file: a filename or :class:`file`-like object :param filename: an optional filename :param content_type: an optional content type