DataService's serialize method now returns whole serialization dict (also passed to frontend)

This commit is contained in:
Mose Müller 2024-01-23 13:13:07 +01:00
parent bcabd2dc48
commit a2518671da
4 changed files with 8 additions and 8 deletions

View File

@ -248,7 +248,7 @@ class DataService(rpyc.Service, AbstractDataService):
Returns:
dict: The serialized instance.
"""
return Serializer.serialize_object(self)["value"]
return Serializer.serialize_object(self)
def update_DataService_attribute( # noqa: N802
self,

View File

@ -30,10 +30,10 @@ class DataServiceCache:
self._cache = self.service.serialize()
def update_cache(self, full_access_path: str, value: Any) -> None:
set_nested_value_by_path(self._cache, full_access_path, value)
set_nested_value_by_path(self._cache["value"], full_access_path, value)
def get_value_dict_from_cache(self, full_access_path: str) -> dict[str, Any]:
try:
return get_nested_dict_by_path(self._cache, full_access_path)
return get_nested_dict_by_path(self._cache["value"], full_access_path)
except (SerializationPathError, SerializationValueError, KeyError):
return {}

View File

@ -126,7 +126,7 @@ class StateManager:
if self.filename is not None:
with open(self.filename, "w") as f:
json.dump(self.cache, f, indent=4)
json.dump(self.cache["value"], f, indent=4)
else:
logger.info(
"State manager was not initialised with a filename. Skipping "
@ -191,7 +191,7 @@ class StateManager:
value: The new value to set for the attribute.
"""
current_value_dict = get_nested_dict_by_path(self.cache, path)
current_value_dict = get_nested_dict_by_path(self.cache["value"], path)
# This will also filter out methods as they are 'read-only'
if current_value_dict["readonly"]:
@ -234,7 +234,7 @@ class StateManager:
# Update path to reflect the attribute without list indices
path = ".".join([*parent_path_list, attr_name])
attr_cache_type = get_nested_dict_by_path(self.cache, path)["type"]
attr_cache_type = get_nested_dict_by_path(self.cache["value"], path)["type"]
# Traverse the object according to the path parts
target_obj = get_object_attr_from_path_list(self.service, parent_path_list)
@ -273,7 +273,7 @@ class StateManager:
return has_decorator
cached_serialization_dict = get_nested_dict_by_path(
self.cache, full_access_path
self.cache["value"], full_access_path
)
if cached_serialization_dict["value"] == "method":

View File

@ -126,7 +126,7 @@ class WebServer:
@property
def web_settings(self) -> dict[str, dict[str, Any]]:
current_web_settings = self._get_web_settings_from_file()
for path in generate_serialized_data_paths(self.state_manager.cache):
for path in generate_serialized_data_paths(self.state_manager.cache["value"]):
if path in current_web_settings:
continue