This compnent enables external configuration via a JSON-File.
The definition of the config is done via en extensive Callback. To create the definition you need to return a dictionary containing Definition values. The possible values are passed as arguments to the GetConfigSchema callback.
Methods
LoadConfig( configStr: str = "" )
Forces the configComp to reload the contents.
It traverses several possibilitites:
- Check the configStr. If the configStr is a valid JsonString, it will be used.
- Check the GetConfigData Callback. Return data as a jsonString.
- Saved file on Disk.
After the Config is loaded, the data will be sanitized, validated and saved to the configFile!
Callbacks passes a configModule as an argument comtaining the following classes.
class EnumValue(_dependencyCopyCallable):
"""An Enum value where the given values need to satisfy the allowedValue passed on init."""
def __init__(self, default='', allowedValues=[], validator=lambda value: True, comment='', parser=None):
pass
class ConfigValue(_dependencyCopyCallable):
"""A generic value which allows to be bound to. Use .Value to refference the Value
and .Dependency to bind to the value."""
def __init__(self, default='', validator=lambda value: True, comment='', parser=None, typecheck=None):
pass
class CollectionDict(dict, _copyCallable):
"""A dictionary where all given keys need to be satisfied."""
def __init__(self, items: dict=None, comment=''):
pass
class NamedList(dict, _copyCallable):
"""Represents a Dictionary with an arbitrary number
of keys where the values need to satisfy the default_member."""
def __init__(self, items: dict=None, default_member=None, comment=''):
pass
class CollectionList(list, _copyCallable):
"""Represents a list or array of values which need to fullfill the default_member."""
def __init__(self, items: list=None, default_member=None, comment=''):
pass
To acces the members use the Data-Attribute. ColectionValues have Value and Dependency members. Use Value for explicit use of the value.
op("json_config").Data.MyValue
op("json_config").Data.MyValue.Dependency #T bind to the value
op("json_config").Data.MyValue.Value #For explicit read-access to the value itself.
Use the "Save" method or Pulseparameter to writte bound values in to the config itself.
Under Windows use
setx [variable_name] "[variable_value]"
to permanently set the env-variable, or a simple
set TD_ENV=variablevalue
before starting in a .bat file.