class documentation

class CookieStorage(BaseStorage): (source)

View In Hierarchy

Store messages in a cookie.

Method __init__ Undocumented
Class Variable cookie_name Undocumented
Class Variable key_salt Undocumented
Class Variable max_cookie_size Undocumented
Class Variable not_finished Undocumented
Instance Variable signer Undocumented
Instance Variable used Undocumented
Method _decode Safely decode an encoded text stream back into a list of messages.
Method _encode Return an encoded version of the messages list which can be stored as plain text.
Method _get Retrieve a list of messages from the messages cookie. If the not_finished sentinel value is found at the end of the message list, remove it and return a result indicating that not all messages were retrieved by this storage.
Method _store Store the messages to a cookie and return a list of any messages which could not be stored.
Method _update_cookie Either set the cookie with the encoded data if there is any data to store, or delete the cookie.

Inherited from BaseStorage:

Method __contains__ Undocumented
Method __iter__ Undocumented
Method __len__ Undocumented
Method __repr__ Undocumented
Method add Queue a message to be stored.
Method update Store all unread messages.
Class Variable level Undocumented
Instance Variable added_new Undocumented
Instance Variable request Undocumented
Method _get_level Return the minimum recorded level.
Method _prepare_messages Prepare a list of messages for storage.
Method _set_level Set a custom minimum recorded level.
Instance Variable _level Undocumented
Instance Variable _queued_messages Undocumented
Property _loaded_messages Return a list of loaded messages, retrieving them first if they have not been loaded yet.
def __init__(self, *args, **kwargs): (source)
cookie_name: str = (source)

Undocumented

key_salt: str = (source)

Undocumented

max_cookie_size: int = (source)

Undocumented

not_finished: str = (source)

Undocumented

Undocumented

def _decode(self, data): (source)

Safely decode an encoded text stream back into a list of messages. If the encoded text stream contained an invalid hash or was in an invalid format, return None.

def _encode(self, messages, encode_empty=False): (source)

Return an encoded version of the messages list which can be stored as plain text. Since the data will be retrieved from the client-side, the encoded data also contains a hash to ensure that the data was not tampered with.

def _get(self, *args, **kwargs): (source)

Retrieve a list of messages from the messages cookie. If the not_finished sentinel value is found at the end of the message list, remove it and return a result indicating that not all messages were retrieved by this storage.

def _store(self, messages, response, remove_oldest=True, *args, **kwargs): (source)

Store the messages to a cookie and return a list of any messages which could not be stored. If the encoded data is larger than ``max_cookie_size``, remove messages until the data fits (these are the messages which are returned), and add the not_finished sentinel value to indicate as much.

def _update_cookie(self, encoded_data, response): (source)

Either set the cookie with the encoded data if there is any data to store, or delete the cookie.