Clean-up CoreConfig a bit
This commit is contained in:
parent
df21107e3f
commit
56735452a8
|
@ -32,10 +32,16 @@ class CoreConfig(component.Component):
|
||||||
log.debug("CoreConfig init..")
|
log.debug("CoreConfig init..")
|
||||||
component.Component.__init__(self, "CoreConfig")
|
component.Component.__init__(self, "CoreConfig")
|
||||||
self.config = {}
|
self.config = {}
|
||||||
client.register_event_handler("ConfigValueChangedEvent", self.on_configvaluechanged_event)
|
def on_configvaluechanged_event(key, value):
|
||||||
|
self.config[key] = value
|
||||||
|
client.register_event_handler("ConfigValueChangedEvent", on_configvaluechanged_event)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self.start_defer = client.core.get_config().addCallback(self._on_get_config)
|
def on_get_config(config):
|
||||||
|
self.config = config
|
||||||
|
return config
|
||||||
|
|
||||||
|
self.start_defer = client.core.get_config().addCallback(on_get_config)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.config = {}
|
self.config = {}
|
||||||
|
@ -46,12 +52,6 @@ class CoreConfig(component.Component):
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
client.core.set_config({key: value})
|
client.core.set_config({key: value})
|
||||||
|
|
||||||
def _on_get_config(self, config):
|
|
||||||
self.config = config
|
|
||||||
|
|
||||||
def on_configvaluechanged_event(self, key, value):
|
|
||||||
self.config[key] = value
|
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
# We treat this directly interacting with the dictionary
|
# We treat this directly interacting with the dictionary
|
||||||
return getattr(self.config, attr)
|
return getattr(self.config, attr)
|
||||||
|
|
Loading…
Reference in New Issue