Commit 025b234
committed
[IMP] snippets: preserve same file module
In `make_pickleable_callback`, when creating a name for the module created via
import_script, no longer make the name random, but derive it from the script's
path deterministically via a hash function. This way, when this method is
called multiple times from the same script for multiple callbacks, it will only
import the script once and otherwise re-use the created module. This ensures
multiple callbacks from the same script file will run within the same module,
seeing e.g. the same values in modified globals, which is much more intuitive.
Also, move the function to `misc.py`. With the intention to reuse it, it's a
better fit. For that, make it python2 compatible.
closes #295
Related: odoo/upgrade#8047
Signed-off-by: Christophe Simonis (chs) <[email protected]>1 parent eab584e commit 025b234
2 files changed
+30
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | | - | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
391 | 394 | | |
392 | 395 | | |
393 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
394 | 422 | | |
395 | 423 | | |
396 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | | - | |
7 | 4 | | |
8 | 5 | | |
9 | 6 | | |
| |||
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
15 | | - | |
16 | 12 | | |
17 | | - | |
| 13 | + | |
18 | 14 | | |
19 | 15 | | |
20 | 16 | | |
| |||
161 | 157 | | |
162 | 158 | | |
163 | 159 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | 160 | | |
187 | 161 | | |
188 | 162 | | |
| |||
0 commit comments