Event Module (1.7.0)
Functions
publish(name, attributes, time_to_live=None)
Publish a Universal Event to the associated Universal Controller.
- Can be called at any time by an Extension instance.
- Universal Events are optionally defined in the Universal Extension Template as part of the Universal Extension definition.
Parameters
name : str
The name of a target event defined in the Controller.
attributes : dict
the attributes of the event
time_to_live : int, optional
maximum time (in minutes) the event can live. If no value is specified, the default value from the Universal Event Template will be used.
Returns
None
Raises
ValueError
- If
nameis not of typestr - If
time_to_liveis not of typeintor less than 0 - If the attribute values are not of type
str,float,int,bool, or a list ofstr/float/int/bool(mixed-types NOT allowed)
Examples
>>> from universal_extension import event
>>> event_attributes = {}
>>> event_attributes["attribute_1"] = "value_1"
>>> event_attributes["attribute_2"] = 123
>>> event_attributes["attribute_3"] = False
>>> event_attributes["attribute_4"] = [1.23, 4.56, 8.09]
>>> event.publish("my_event", event_attributes, 20)