diff libervia/web/server/server.py @ 1618:5d9889f14012 default tip @

server: start major redesign - Add icons to menu items - Switch menu items representation from tuple to dictionary for future extensibility: - Include icon information - Prepare for additional data - Remove "login" from main menu, add login page URL to template data, as it is now a separate right-aligned item
author Goffi <goffi@goffi.org>
date Sat, 26 Oct 2024 23:07:01 +0200
parents ebd538cb26cb
children
line wrap: on
line diff
--- a/libervia/web/server/server.py	Wed Aug 07 00:02:40 2024 +0200
+++ b/libervia/web/server/server.py	Sat Oct 26 23:07:01 2024 +0200
@@ -305,15 +305,17 @@
             '/', C.TPL_RESOURCE, template_data.site or C.SITE_NAME_DEFAULT,
             C.TEMPLATE_TPL_DIR, template_data.theme, relative_url)
 
-    def _move_first_level_to_dict(self, options, key, keys_to_keep):
-        """Read a config option and put value at first level into u'' dict
+    def _move_first_level_to_dict(
+        self, options: dict, key: str, keys_to_keep: list[str]
+    ) -> None:
+        """Read a config option and put value at first level into '' dict
 
         This is useful to put values for Libervia official site directly in dictionary,
         and to use site_name as keys when external sites are used.
         options will be modified in place
-        @param options(dict): options to modify
-        @param key(unicode): setting key to modify
-        @param keys_to_keep(list(unicode)): keys allowed in first level
+        @param options: Dictionary of options to modify in place.
+        @param key: The key in the options dictionary to process.
+        @param keys_to_keep: List of keys that are allowed to remain at the first level.
         """
         try:
             conf = options[key]
@@ -476,7 +478,12 @@
         if not '' in menu:
             menu[''] = C.DEFAULT_MENU
         for site, value in self.options["menu_extra_json"].items():
-            menu[site].extend(value)
+            try:
+                menu[site].extend(value)
+            except KeyError:
+                log.warning(
+                    "Configuration error: the key {site!r} is missing from \"menu_json\"."
+                )
 
         # service profile
         if not self.options['build-only']: