Module QFlow.helpers.sessionStorage

Classes

class SessionStorage
Expand source code
@dataclass
class SessionStorage:
    """
    A class that simulates session storage in memory.

    This class provides methods for storing, retrieving, and removing key-value pairs
    in memory, which mimics a session storage mechanism. The storage is global across
    all instances of the application.

    Attributes:
        _storage (dict): A dictionary to store session data.
    """
    
    _storage = {}

    def getItem(self, item: str):
        """
        Retrieves an item from the session storage.

        Args:
            item (str): The key of the item to retrieve.

        Returns:
            The value associated with the provided key, or None if the key does not exist.
        """
        return self._storage.get(item)

    def setItem(self, name: str, value) -> None:
        """
        Adds or updates an item in the session storage.

        Args:
            name (str): The key to store the item under.
            value: The value to associate with the given key.
        """
        self._storage[name] = value
    
    def removeItem(self, item: str) -> None:
        """
        Removes an item from the session storage.

        Args:
            item (str): The key of the item to remove.
        """
        self._storage.pop(item, None)

A class that simulates session storage in memory.

This class provides methods for storing, retrieving, and removing key-value pairs in memory, which mimics a session storage mechanism. The storage is global across all instances of the application.

Attributes

_storage : dict
A dictionary to store session data.

Methods

def getItem(self, item: str)
Expand source code
def getItem(self, item: str):
    """
    Retrieves an item from the session storage.

    Args:
        item (str): The key of the item to retrieve.

    Returns:
        The value associated with the provided key, or None if the key does not exist.
    """
    return self._storage.get(item)

Retrieves an item from the session storage.

Args

item : str
The key of the item to retrieve.

Returns

The value associated with the provided key, or None if the key does not exist.

def removeItem(self, item: str) ‑> None
Expand source code
def removeItem(self, item: str) -> None:
    """
    Removes an item from the session storage.

    Args:
        item (str): The key of the item to remove.
    """
    self._storage.pop(item, None)

Removes an item from the session storage.

Args

item : str
The key of the item to remove.
def setItem(self, name: str, value) ‑> None
Expand source code
def setItem(self, name: str, value) -> None:
    """
    Adds or updates an item in the session storage.

    Args:
        name (str): The key to store the item under.
        value: The value to associate with the given key.
    """
    self._storage[name] = value

Adds or updates an item in the session storage.

Args

name : str
The key to store the item under.
value
The value to associate with the given key.