pyrtma.validators.ContextVar

class ContextVar

Bases: object

Methods

get

Return a value for the context variable for the current context.

reset

Reset the context variable.

set

Call to set a new value for the context variable in the current context.

Attributes

name

get()

Return a value for the context variable for the current context.

If there is no value for the variable in the current context, the method will:
  • return the value of the default argument of the method, if provided; or

  • return the default value for the context variable, if it was created with one; or

  • raise a LookupError.

reset(token, /)

Reset the context variable.

The variable is reset to the value it had before the ContextVar.set() that created the token was used.

set(value, /)

Call to set a new value for the context variable in the current context.

The required value argument is the new value for the context variable.

Returns a Token object that can be used to restore the variable to its previous value via the ContextVar.reset() method.