diff --git a/selfprivacy_api/graphql/mutations/services_mutations.py b/selfprivacy_api/graphql/mutations/services_mutations.py index 704fc96..2b34a32 100644 --- a/selfprivacy_api/graphql/mutations/services_mutations.py +++ b/selfprivacy_api/graphql/mutations/services_mutations.py @@ -172,6 +172,8 @@ class ServicesMutations: self, input: SetServiceConfigurationInput ) -> ServiceMutationReturn: """Set the new configuration values""" + print('set_service_configuration') + print(f"{input=}") service = get_service_by_id(input.service_id) if service is None: return ServiceMutationReturn( @@ -180,7 +182,9 @@ class ServicesMutations: code=404, ) try: + print('Got service by id.') service.set_configuration(input.configuration) + print('Configuration set.') return ServiceMutationReturn( success=True, message="Service configuration updated.", diff --git a/selfprivacy_api/services/config_item.py b/selfprivacy_api/services/config_item.py index abddd46..94de486 100644 --- a/selfprivacy_api/services/config_item.py +++ b/selfprivacy_api/services/config_item.py @@ -57,10 +57,12 @@ class StringServiceConfigItem(ServiceConfigItem): return service_options.get(self.id, self.default_value) def set_value(self, value, service_options): + print('set_value called') if not self.validate_value(value): raise ValueError(f"Value {value} is not valid") if self.regex and not self.regex.match(value): raise ValueError(f"Value {value} does not match regex {self.regex}") + print('seting actual value') service_options[self.id] = value def as_dict(self, service_options): diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index 6d6bd47..df68f6b 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -202,17 +202,30 @@ class Service(ABC): @classmethod def set_configuration(cls, config_items): + print('set_configuration') + print(f'{config_items=}') + print('Starting pre-check for config items') for key, value in config_items.items(): + print(f'{key=}') + print(f'{value=}') if key not in cls.config_items: raise ValueError(f"Key {key} is not valid for {cls.get_id()}") + print('key in cls.config_items') if cls.config_items[key].validate_value(value) is False: raise ValueError(f"Value {value} is not valid for {key}") + print('value is valid') with WriteUserData() as user_data: + print('Writing to user_data') if "modules" not in user_data: + print('modules not in user_data') user_data["modules"] = {} if cls.get_id() not in user_data["modules"]: + print('cls.get_id() not in user_data["modules"]') user_data["modules"][cls.get_id()] = {} for key, value in config_items.items(): + print('Starting writing') + print(f'{key=}') + print(f'{value=}') cls.config_items[key].set_value( value, user_data["modules"][cls.get_id()],