Skip to content

Commit 49c6b05

Browse files
author
Mark Gibbs
committed
Refactor formation of dash instance to clarify name generation
1 parent 64fe81d commit 49c6b05

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

django_plotly_dash/dash_wrapper.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def as_dash_instance(self):
6060
'''
6161
Form a dash instance, for stateless use of this app
6262
'''
63-
return self.form_dash_instance()
63+
return self.do_form_dash_instance()
6464

6565
def handle_current_state(self):
6666
'Do nothing impl - only matters if state present'
@@ -72,27 +72,26 @@ def have_current_state_entry(self, wid, key):
7272
'Do nothing impl - only matters if state present'
7373
pass
7474

75-
def get_base_pathname(self, specific_identifier, stub=None):
75+
def get_base_pathname(self, specific_identifier):
7676
if not specific_identifier:
7777
app_pathname = "%s:app-%s"% (app_name, main_view_label)
7878
ndid = self._uid
7979
else:
8080
app_pathname="%s:%s" % (app_name, main_view_label)
8181
ndid = specific_identifier
8282

83-
try:
84-
full_url = reverse(app_pathname,kwargs={'id':ndid})
85-
except:
86-
if stub is not None:
87-
full_url = "%s/%s/" %(stub,ndid)
88-
else:
89-
full_url = "/%s/"%ndid
90-
83+
full_url = reverse(app_pathname,kwargs={'id':ndid})
9184
return ndid, full_url
9285

93-
def form_dash_instance(self, replacements=None, specific_identifier=None, stub=None):
86+
def do_form_dash_instance(self, replacements=None, specific_identifier=None):
9487

95-
ndid, base_pathname = self.get_base_pathname(specific_identifier, stub)
88+
ndid, base_pathname = self.get_base_pathname(specific_identifier)
89+
return self.form_dash_instance(replacements, ndid, base_pathname)
90+
91+
def form_dash_instance(self, replacements=None, ndid=None, base_pathname=None):
92+
93+
if ndid is None:
94+
ndid = self._uid
9695

9796
rd = WrappedDash(base_pathname=base_pathname,
9897
expanded_callbacks = self._expanded_callbacks,

django_plotly_dash/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def current_state(self):
8484
def as_dash_instance(self):
8585
dd = self._stateless_dash_app()
8686
base = self.current_state()
87-
return dd.form_dash_instance(replacements=base,
88-
specific_identifier=self.slug)
87+
return dd.do_form_dash_instance(replacements=base,
88+
specific_identifier=self.slug)
8989

9090
def _get_base_state(self):
9191
'''

0 commit comments

Comments
 (0)