Repository: Avaiga/taipy
Pull request: Fix MapDict refresh error (#464)
Resolve #464

Problem statement:
BUG-Error when calling 'refresh' with dataframes
**Description**
An error occurs when refresh is being used inside a function and called twice.

```
TaipyGuiWarning: on_action(): Exception raised in 'change()':
maximum recursion depth exceeded
TaipyGuiWarning: on_action(): 'change' is not a valid function.
```

**How to reproduce**
Call twice this function:

```python
from taipy.gui import Gui

data = {
    "x": [1, 2, 3],
    "y": [1, 2, 3],
    "y2": [4, 5, 1],
}

properties = {
    "x":"x",
    "y[1]":"y",
    "y[2]":"y2",
}

def change(state):
    state.data['y3'] = [14, 15, 11]
    state.refresh('data')
    print(state.data._dict)

Gui("<|{data}|chart|properties={properties}|> <|change|button|on_action=change|>").run()
```


**Expected behavior**
Calling this function again and again shouldn't cause any problem.

**Runtime environment**
Taipy 2.4

Hints from issue discussion:

Commit message: Fix MapDict refresh error

Patch to review:
diff --git a/taipy/gui/utils/_bindings.py b/taipy/gui/utils/_bindings.py
index 6a5185d0b4..bbbca379c4 100644
--- a/taipy/gui/utils/_bindings.py
+++ b/taipy/gui/utils/_bindings.py
@@ -39,6 +39,8 @@ def _bind(self, name: str, value: t.Any) -> None:
 
     def __get_property(self, name):
         def __setter(ud: _Bindings, value: t.Any):
+            if isinstance(value, _MapDict):
+                value._update_var = None
             if isinstance(value, dict):
                 value = _MapDict(value, None)
             ud.__gui._update_var(name, value)


Code review comments:
diff_hunk: @@ -39,6 +39,8 @@ def _bind(self, name: str, value: t.Any) -> None:
 
     def __get_property(self, name):
         def __setter(ud: _Bindings, value: t.Any):
+            if isinstance(value, _MapDict):
+                value._update_var = None
             if isinstance(value, dict):
path: taipy/gui/utils/_bindings.py
text: @user1:
So what will become a `elif` right?

@author:
elif is fine too but not necessary :D

@author:
I change it anyway

@user1:
Well you avoid a test...