Browse Source

evaluate expression in different client context (#2463)

* force table column width
resolves #2406
resolves taipy-enterprise#603

* do not break on evaluating expression in a client context that doesn't match.
resolves #2441

* show warning only in debug mode

---------

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide 2 months ago
parent
commit
cf9f976645
2 changed files with 8 additions and 2 deletions
  1. 2 0
      taipy/gui/gui.py
  2. 6 2
      taipy/gui/utils/_evaluator.py

+ 2 - 0
taipy/gui/gui.py

@@ -2298,6 +2298,8 @@ class Gui:
         partial = partials.get(route)
         if partial is None:
             partial = next((p for p in self._config.partials if p._route == route), None)
+            partials[route] = partial
+            _setscopeattr(self, Partial._PARTIALS, partials)
         return partial
 
     # Main binding method (bind in markdown declaration)

+ 6 - 2
taipy/gui/utils/_evaluator.py

@@ -35,6 +35,7 @@ from . import (
     _TaipyBase,
     _variable_decode,
     _variable_encode,
+    is_debugging,
 )
 
 
@@ -374,14 +375,17 @@ class _Evaluator:
                         expr_evaluated = eval(expr_string, ctx)
                         _setscopeattr(gui, hash_expr, expr_evaluated)
                     except Exception as e:
-                        _warn(f"Exception raised evaluating {_Evaluator._clean_exception_expr(expr_string)}", e)
+                        if is_debugging():
+                            _warn(f"Exception raised evaluating {_Evaluator._clean_exception_expr(expr_string)}", e)
+                        hash_expr = ""
             # refresh holders if any
             for h in self.__expr_to_holders.get(expr, []):
                 holder_hash = self.__get_holder_hash(h, self.get_hash_from_expr(expr))
                 if holder_hash not in modified_vars:
                     _setscopeattr(gui, holder_hash, self.__evaluate_holder(gui, h, expr))
                     modified_vars.add(holder_hash)
-            modified_vars.add(hash_expr)
+            if hash_expr:
+                modified_vars.add(hash_expr)
         return modified_vars
 
     def _get_instance_in_context(self, name: str):