From 28c2dcd2f7d81de9a93200d0561da3c28515af51 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Mon, 15 Sep 2025 11:40:29 -0400 Subject: [PATCH] fix dict class for web ui --- web_interface_v2.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/web_interface_v2.py b/web_interface_v2.py index 4c16b5a0..48d2b78d 100644 --- a/web_interface_v2.py +++ b/web_interface_v2.py @@ -76,12 +76,23 @@ class DictWrapper: self._value = data def __getattr__(self, name): - # Return None for missing attributes to avoid template errors - return None + # Return a new DictWrapper with empty dict for missing attributes + # This allows chaining like main_config.display.hardware.rows + return DictWrapper({}) def __getitem__(self, key): # Support bracket notation as fallback - return getattr(self, key, None) + return getattr(self, key, DictWrapper({})) + + def items(self): + # Support .items() method for iteration + if hasattr(self, '_value'): + return {} + return {k: v for k, v in self.__dict__.items() if not k.startswith('_')} + + def get(self, key, default=None): + # Support .get() method + return getattr(self, key, default) class DisplayMonitor: def __init__(self):