Details
-
Type:
RFC
-
Status: Implemented
-
Resolution: Done
-
Component/s: T&S
-
Labels:None
Description
The current ts_scriptqueue Script code validates configuration by parsing it as a dict and passing it as keyword arguments to the configure method. I wrote that before I knew about jsonschema. I propose overhauling this to use jsonschema as follows:
- SAL scripts must override classmethod get_schema to return a jsonschema schema describing valid configuration.
- BaseScript will validate configuration against that schema and, assuming it is OK, pass the resulting configuration as a types.SimpleNamespace instance (this is a standard Python class that offers struct-like attribute access to dicts) to the configure method.
- BaseScripts's constructor will also validate the schema and raise an exception if the schema is invalid.
A less invasive version of this proposal is to continue to pass the parsed and validated configuration as a keyword argument dict to the configure method. But I think SimpleNamespace is nicer, and this will make SAL scripts work the same way as configurable CSCs.
If accepted I will convert all existing scripts on the develop branch of ts_standardscripts and ts_externalscripts. We don't have many yet, so this is a good time to make such a change.
Adopted as stated, including passing configuration to scripts as types.SimpleNamespace instances.