Skip to content

Commit 6d35979

Browse files
delsimGibbsConsulting
authored andcommitted
Add renderer handling for dash v0.39.0 and later (#139)
* Enable use of newer dash versions that require interpolate index functionality to include renderer information * Temporary restriction to prevent use of multiple callback outputs * Bump version to 0.9.9 * Updated used package version list
1 parent ce3a6b0 commit 6d35979

File tree

5 files changed

+51
-37
lines changed

5 files changed

+51
-37
lines changed

django_plotly_dash/dash_wrapper.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,15 @@ def _fix_callback_item(self, item):
437437

438438
def callback(self, output, inputs=[], state=[], events=[]): # pylint: disable=dangerous-default-value
439439
'Invoke callback, adjusting variable names as needed'
440-
return super(WrappedDash, self).callback(self._fix_callback_item(output),
440+
441+
if isinstance(output, (list, tuple)):
442+
fixed_outputs = [self._fix_callback_item(x) for x in output]
443+
# Temporary check; can be removed once the library has been extended
444+
raise NotImplementedError("django-plotly-dash cannot handle multiple callback outputs at present")
445+
else:
446+
fixed_outputs = self._fix_callback_item(output)
447+
448+
return super(WrappedDash, self).callback(fixed_outputs,
441449
[self._fix_callback_item(x) for x in inputs],
442450
[self._fix_callback_item(x) for x in state])
443451

@@ -520,6 +528,7 @@ def index(self, *args, **kwargs): # pylint: disable=unused-argument
520528
css = self._generate_css_dist_html()
521529
config = self._generate_config_html()
522530
metas = self._generate_meta_html()
531+
renderer = self._generate_renderer()
523532
title = getattr(self, 'title', 'Dash')
524533
if self._favicon:
525534
import flask
@@ -537,14 +546,13 @@ def index(self, *args, **kwargs): # pylint: disable=unused-argument
537546
'''
538547
index = self.interpolate_index(
539548
metas=metas, title=title, css=css, config=config,
540-
scripts=scripts, app_entry=_app_entry, favicon=favicon)
549+
scripts=scripts, app_entry=_app_entry, favicon=favicon,
550+
renderer=renderer)
541551

542552
return index
543553

544554
def interpolate_index(self, **kwargs): #pylint: disable=arguments-differ
545555

546-
print("IN INTERPOLATE INDEX")
547-
548556
if not self._return_embedded:
549557
resp = super(WrappedDash, self).interpolate_index(**kwargs)
550558
return resp

django_plotly_dash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
2424
'''
2525

26-
__version__ = "0.9.8"
26+
__version__ = "0.9.9"

django_plotly_dash/views.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,16 @@ def update(request, ident, stateless=False, **kwargs):
9090
if str(resp) == 'EDGECASEEXIT':
9191
return HttpResponse("")
9292

93-
return HttpResponse(resp.data,
94-
content_type=resp.mimetype)
93+
# Change in returned value type
94+
try:
95+
rdata = resp.data
96+
rtype = resp.mimetype
97+
except:
98+
rdata = resp
99+
rtype = "application/json"
100+
101+
return HttpResponse(rdata,
102+
content_type=rtype)
95103

96104
def main_view(request, ident, stateless=False, cache_id=None, **kwargs):
97105
'Main view for a dash app'

frozen_dev.txt

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,35 @@ astroid==2.0.4
66
async-timeout==2.0.1
77
atomicwrites==1.2.1
88
attrs==18.2.0
9-
autobahn==18.9.2
9+
autobahn==18.8.2
1010
Automat==0.7.0
1111
Babel==2.6.0
12-
bleach==3.0.2
1312
certifi==2018.8.24
14-
cffi==1.11.5
1513
channels==2.1.3
1614
channels-redis==2.3.0
1715
chardet==3.0.4
18-
Click==7.0
19-
cmarkgfm==0.4.2
16+
click==6.7
2017
constantly==15.1.0
2118
coverage==4.5.1
2219
daphne==2.2.2
23-
dash==0.36
24-
dash-core-components==0.43
25-
dash-html-components==0.13.5
26-
dash-renderer==0.17
20+
dash==0.41.0
21+
dash-bootstrap-components==0.2.6
22+
dash-core-components==0.46.0
23+
dash-html-components==0.15.0
24+
dash-renderer==0.22.0
25+
dash-table==3.6.0
2726
decorator==4.3.0
28-
Django==2.1.2
27+
Django==2.1.1
2928
django-bootstrap4==0.0.7
30-
-e git+https://github.com/delsim/django-plotly-dash.git@affccd8b280b2fdbc7f7e2d975b9cf4c7ace5f06#egg=django_plotly_dash
29+
django-pdb==0.6.2
30+
-e git+https://github.com/delsim/django-plotly-dash.git@883dbd9969a993cfb5a5b34c62b658f13ac0d613#egg=django_plotly_dash
3131
django-redis==4.9.0
3232
docopt==0.6.2
3333
docutils==0.14
3434
dpd-components==0.1.0
35+
dpd-static-support==0.0.2
3536
Flask==1.0.2
3637
Flask-Compress==1.4.0
37-
future==0.16.0
3838
grip==4.5.2
3939
hiredis==0.2.0
4040
hyperlink==18.0.0
@@ -49,36 +49,34 @@ jsonschema==2.6.0
4949
jupyter-core==4.4.0
5050
lazy-object-proxy==1.3.1
5151
livereload==2.5.2
52-
Markdown==3.0.1
52+
Markdown==2.6.11
5353
MarkupSafe==1.0
5454
mccabe==0.6.1
5555
more-itertools==4.3.0
5656
msgpack==0.5.6
5757
nbformat==4.4.0
58-
numpy==1.15.2
58+
numpy==1.15.1
5959
packaging==18.0
6060
pandas==0.23.4
6161
path-and-address==2.0.1
6262
pathlib2==2.3.2
6363
pathtools==0.1.2
6464
pkg-resources==0.0.0
6565
pkginfo==1.4.2
66-
plotly==3.5.0
66+
plotly==3.4.2
6767
pluggy==0.7.1
6868
port-for==0.3.1
69-
py==1.7.0
70-
pycparser==2.19
69+
py==1.6.0
7170
Pygments==2.2.0
7271
PyHamcrest==1.9.0
7372
pylint==2.1.1
74-
pyparsing==2.2.2
75-
pytest==3.8.2
76-
pytest-cov==2.6.0
77-
pytest-django==3.4.3
73+
pyparsing==2.3.0
74+
pytest==3.7.4
75+
pytest-cov==2.5.1
76+
pytest-django==3.4.2
7877
python-dateutil==2.7.3
7978
pytz==2018.5
8079
PyYAML==3.13
81-
readme-renderer==22.0
8280
redis==2.10.6
8381
requests==2.19.1
8482
requests-toolbelt==0.8.0
@@ -89,16 +87,16 @@ Sphinx==1.8.1
8987
sphinx-autobuild==0.7.1
9088
sphinx-rtd-theme==0.4.2
9189
sphinxcontrib-websupport==1.1.0
92-
tornado==5.1.1
93-
tqdm==4.26.0
90+
tornado==5.1
91+
tqdm==4.25.0
9492
traitlets==4.3.2
95-
twine==1.12.1
93+
twine==1.11.0
9694
Twisted==18.7.0
9795
txaio==18.8.1
9896
typed-ast==1.1.0
9997
urllib3==1.23
10098
watchdog==0.9.0
101-
webencodings==0.5.1
10299
Werkzeug==0.14.1
100+
whitenoise==4.1.2
103101
wrapt==1.10.11
104102
zope.interface==4.5.0

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dash==0.38
2-
dash-core-components==0.43.1
3-
dash-html-components==0.13.5
4-
dash-renderer==0.19
1+
dash
2+
dash-core-components
3+
dash-html-components
4+
dash-renderer
55
plotly
66
dpd-components
77

0 commit comments

Comments
 (0)