Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #394 from Avaiga/backport/#392-AttributeError-on-r…
Browse files Browse the repository at this point in the history
…e-evaluation

Backport: AttributeError on re evaluation (#392)
  • Loading branch information
FredLL-Avaiga authored Sep 3, 2022
2 parents 1207243 + 922bf1c commit 23123e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion taipy/gui/utils/_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def re_evaluate_expr(self, gui: Gui, var_name: str) -> t.Set[str]:
if expr_var_map is None:
warnings.warn(f"Something is amiss with expression list for {expr}")
else:
eval_dict = {k: _getscopeattr_drill(gui, v) for k, v in expr_var_map.items()}
eval_dict = {k: _getscopeattr_drill(gui, gui._bind_var(v)) for k, v in expr_var_map.items()}
if self._is_expression(expr_decoded):
expr_string = 'f"' + _variable_decode(expr)[0].replace('"', '\\"') + '"'
else:
Expand Down
17 changes: 17 additions & 0 deletions tests/taipy/gui/utils/test_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import inspect
import warnings

from flask import g

from taipy.gui import Gui
from taipy.gui.utils.types import _TaipyNumber

Expand Down Expand Up @@ -68,3 +70,18 @@ def test_evaluate_not_expression_type(gui: Gui):
gui.run(run_server=False)
with gui.get_flask_app().app_context():
assert "x + 10" == gui._evaluate_expr("x + 10")


def test_evaluate_expression_2_clients(gui: Gui):
x = 10 # noqa: F841
y = 20 # noqa: F841
gui._set_frame(inspect.currentframe())
gui.run(run_server=False)
with gui.get_flask_app().app_context():
gui._bindings()._get_or_create_scope("A")
gui._bindings()._get_or_create_scope("B")
g.client_id = "A"
gui._evaluate_expr("x + y = {x + y}")
g.client_id = "B"
gui._evaluate_expr("x")
gui._re_evaluate_expr("x")

0 comments on commit 23123e7

Please sign in to comment.