duck.http.querydict¶
Module for implementation of a basic Query Dictionary
Module Contents¶
Classes¶
A custom dictionary-like class that accepts a dictionary with any number of keys. This class does not support deletion or modification of keys but only modification of values. |
|
A dictionary subclass that allows multiple values for a single key. |
API¶
- class duck.http.querydict.FixedQueryDict(data: dict)[source]¶
Bases:
duck.http.querydict.QueryDictA custom dictionary-like class that accepts a dictionary with any number of keys. This class does not support deletion or modification of keys but only modification of values.
Initialization
Initializes the FixedQueryDict with a dictionary of any number of keys.
- Parameters:
data – Dictionary with any number of keys.
- Raises:
ValueError – If the input is not a dictionary.
- __delitem__(key)[source]¶
Raises an error as deletion of keys is not supported.
- Parameters:
key – The key to delete.
- Raises:
KeyError – Always raised as deletion is not supported.
- __getitem__(key)[source]¶
Retrieves the value associated with the given key.
- Parameters:
key – The key to look up.
- Returns:
The value associated with the key.
- __repr__()[source]¶
Returns a string representation of the QueryDict.
- Returns:
String representation of the QueryDict.
- Return type:
str
- __setitem__(key, value)[source]¶
Sets the value for the given key if the key is allowed.
- Parameters:
key – The key to set the value for.
value – The value to set.
- Raises:
KeyError – If the key is not one of the allowed keys.
- __slots__¶
(‘_data’, ‘_keys’)
- class duck.http.querydict.QueryDict[source]¶
Bases:
dictA dictionary subclass that allows multiple values for a single key.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- __getitem__(key: str)[source]¶
Returns the first value for the key, or raises KeyError if the key is missing.
- __slots__¶
()