ContextStack
- class app.util.config.context_stack.ContextStack[source]
Bases:
object
ContextStack(name: str | None = None, parent: ‘ContextStack | None’ = None, current: CurrentType | None = None, token: _contextvars.Token | None = None)
Inheritance Diagram for ContextStack
Methods
__init__
([name, parent, current, token])find_inheritance
(name[, skip])Find a context by name in the stack.
find_name
(name[, skip])Check if a context with the given name exists in the stack.
get
()Get the current context from the stack.
iterate
([skip])Iterate over the current context and all parent contexts.
pop
([token])Pop the current context from the stack and return it.
push
(current[, name])Push a new context onto the stack.
with_context
(cls, current[, name])Context manager to push a new context onto the stack.
with_updated_name
(cls, name)Attributes
- CurrentType = CurrentType
- __init__(name=None, parent=None, current=None, token=None)
- Parameters:
name (str | None)
parent (ContextStack | None)
current (CurrentType | None)
token (Token | None)
- Return type:
None
- classmethod find_name(name, skip=0)[source]
Check if a context with the given name exists in the stack.
- classmethod get()[source]
Get the current context from the stack. If the stack is empty, return None.
- Return type:
- classmethod iterate(skip=0)[source]
Iterate over the current context and all parent contexts.
- Return type:
- Parameters:
skip (int)
-
parent:
ContextStack
|None
= None
- classmethod pop(token=None)[source]
Pop the current context from the stack and return it. If the stack is empty, return None.
- classmethod push(current, name=None)[source]
Push a new context onto the stack.
- Return type:
- Parameters:
current (CurrentType)
name (str | None)