Skip to content

Commit b572091

Browse files
authored
Merge pull request #1719 from plotly/dash-dot-callback-2-jonmmease
CI debugging for dash.callback
2 parents 71ca88a + 6be0b42 commit b572091

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

dash/dash.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -714,17 +714,17 @@ def _generate_scripts_html(self):
714714
)
715715
)
716716

717+
self._inline_scripts.extend(_callback.GLOBAL_INLINE_SCRIPTS)
718+
_callback.GLOBAL_INLINE_SCRIPTS.clear()
719+
717720
return "\n".join(
718721
[
719722
format_tag("script", src)
720723
if isinstance(src, dict)
721724
else '<script src="{}"></script>'.format(src)
722725
for src in srcs
723726
]
724-
+ [
725-
"<script>{}</script>".format(src)
726-
for src in (self._inline_scripts + _callback.GLOBAL_INLINE_SCRIPTS)
727-
]
727+
+ ["<script>{}</script>".format(src) for src in self._inline_scripts]
728728
)
729729

730730
def _generate_config_html(self):
@@ -1343,7 +1343,7 @@ def _setup_server(self):
13431343
self._generate_css_dist_html()
13441344

13451345
# Copy over global callback data structures assigned with `dash.callback`
1346-
for k in _callback.GLOBAL_CALLBACK_MAP:
1346+
for k in list(_callback.GLOBAL_CALLBACK_MAP):
13471347

13481348
if k in self.callback_map:
13491349
raise DuplicateCallback(
@@ -1353,9 +1353,10 @@ def _setup_server(self):
13531353
+ "assigned with `app.callback`."
13541354
)
13551355

1356-
self.callback_map[k] = _callback.GLOBAL_CALLBACK_MAP[k]
1356+
self.callback_map[k] = _callback.GLOBAL_CALLBACK_MAP.pop(k)
13571357

13581358
self._callback_list.extend(_callback.GLOBAL_CALLBACK_LIST)
1359+
_callback.GLOBAL_CALLBACK_LIST.clear()
13591360

13601361
def _add_assets_resource(self, url_path, file_path):
13611362
res = {"asset_path": url_path, "filepath": file_path}
@@ -1434,16 +1435,17 @@ def csp_hashes(self, hash_algorithm="sha256"):
14341435

14351436
method = getattr(hashlib, hash_algorithm)
14361437

1438+
self._inline_scripts.extend(_callback.GLOBAL_INLINE_SCRIPTS)
1439+
_callback.GLOBAL_INLINE_SCRIPTS.clear()
1440+
14371441
return [
14381442
"'{hash_algorithm}-{base64_hash}'".format(
14391443
hash_algorithm=hash_algorithm,
14401444
base64_hash=base64.b64encode(
14411445
method(script.encode("utf-8")).digest()
14421446
).decode("utf-8"),
14431447
)
1444-
for script in (
1445-
self._inline_scripts + [self.renderer] + _callback.GLOBAL_INLINE_SCRIPTS
1446-
)
1448+
for script in (self._inline_scripts + [self.renderer])
14471449
]
14481450

14491451
def get_asset_url(self, path):

dash/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ class ProxyError(DashException):
8484

8585

8686
class DuplicateCallback(DashException):
87-
pass
87+
pass

0 commit comments

Comments
 (0)