Module betterstack.uptime.mixins
This module contains the magic that is the DynamicVariableMixin class. When using this mixin, you can assign variables that track if they get changed, whilst keeping the interface for the user the same. For example:
test = DynamicVariableMixin()
test.add_tracked_property("y", 123)
print(test.y)
test.y = 456
print(test.y)
print(test.get_modified_properties())
Module contents
- class betterstack.uptime.mixins.DynamicVariable(name: str)[source]
Bases:
object
Class to track variables using the descriptor mechanism in python. Stores its data in the class that is assigned this variable using object id’s
Initialize variable. The name variable should be set
- Parameters:
name (str) – Name of the variable
- class betterstack.uptime.mixins.DynamicVariableMixin[source]
Bases:
object
Used to be able to store and keep track of dynamic variables
- add_tracked_property(property_name, property_value=None)[source]
Adds an instance of DynamicVariable to the entire class. If the variable already exists, set the value for this instance.
- Parameters:
property_name (str) – Name of the variable to be added
property_value (any) – Value of the variable