variable
Platypush documentation
variable
- class platypush.plugins.variable.VariablePlugin(**kwargs)[source]
Bases:
Plugin
This plugin allows you to manipulate context variables that can be accessed across your tasks. It requires the
platypush.plugins.db
andplatypush.plugins.redis
plugins to be enabled, as the variables will be stored either persisted on a local database or on the local Redis instance.- __init__(**kwargs)[source]
The plugin will create a table named
variable
on the database configured in theplatypush.plugins.db
plugin. You’ll have to specify a defaultengine
in yourdb
plugin configuration.
- get(name, default_value=None)[source]
Get the value of a variable by name from the local db.
- Parameters:
name (str) – Variable name
default_value – What will be returned if the variable is not defined (default: None)
- Returns:
A map in the format
{"<name>":"<value>"}
- mget(name)[source]
Get the value of a variable by name from Redis.
- Parameters:
name (str) – Variable name
- Returns:
A map in the format
{"<name>":"<value>"}
- mset(**kwargs)[source]
Set a variable or a set of variables on Redis.
- Parameters:
kwargs – Key-value list of variables to set (e.g.
foo='bar', answer=42
)- Returns:
A map with the set variables
- munset(name)[source]
Unset a Redis variable by name if it’s set
- Parameters:
name (str) – Name of the variable to remove