configpanels: optimize _get_toml for domains to not load the whole DNS section stuff when just getting a simple info from another section

This commit is contained in:
Alexandre Aubin 2022-01-29 17:49:45 +01:00
parent 16946372cc
commit bf6252ac1d

View file

@ -481,13 +481,19 @@ class DomainConfigPanel(ConfigPanel):
app_ssowatconf() app_ssowatconf()
def _get_toml(self): def _get_toml(self):
from yunohost.dns import _get_registrar_config_section
toml = super()._get_toml() toml = super()._get_toml()
toml["feature"]["xmpp"]["xmpp"]["default"] = ( toml["feature"]["xmpp"]["xmpp"]["default"] = (
1 if self.entity == _get_maindomain() else 0 1 if self.entity == _get_maindomain() else 0
) )
# Optimize wether or not to load the DNS section,
# e.g. we don't want to trigger the whole _get_registary_config_section
# when just getting the current value from the feature section
filter_key = self.filter_key.split(".") if self.filter_key != "" else []
if not filter_key or filter_key[0] == "dns":
from yunohost.dns import _get_registrar_config_section
toml["dns"]["registrar"] = _get_registrar_config_section(self.entity) toml["dns"]["registrar"] = _get_registrar_config_section(self.entity)
# FIXME: Ugly hack to save the registar id/value and reinject it in _load_current_values ... # FIXME: Ugly hack to save the registar id/value and reinject it in _load_current_values ...
@ -502,6 +508,7 @@ class DomainConfigPanel(ConfigPanel):
super()._load_current_values() super()._load_current_values()
# FIXME: Ugly hack to save the registar id/value and reinject it in _load_current_values ... # FIXME: Ugly hack to save the registar id/value and reinject it in _load_current_values ...
if self.hasattr("registrar_id"):
self.values["registrar"] = self.registar_id self.values["registrar"] = self.registar_id