@@ -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'
@@ -80,21 +80,23 @@ def get_base_pathname(self, specific_identifier):
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- full_url = "/%s/" % ndid
87-
83+ full_url = reverse (app_pathname ,kwargs = {'id' :ndid })
8884 return ndid , full_url
8985
90- def form_dash_instance (self , replacements = None , specific_identifier = None ):
86+ def do_form_dash_instance (self , replacements = None , specific_identifier = None ):
9187
9288 ndid , base_pathname = self .get_base_pathname (specific_identifier )
89+ return self .form_dash_instance (replacements , ndid , base_pathname )
9390
94- rd = NotDash (base_pathname = base_pathname ,
95- expanded_callbacks = self ._expanded_callbacks ,
96- replacements = replacements ,
97- ndid = ndid )
91+ def form_dash_instance (self , replacements = None , ndid = None , base_pathname = None ):
92+
93+ if ndid is None :
94+ ndid = self ._uid
95+
96+ rd = WrappedDash (base_pathname = base_pathname ,
97+ expanded_callbacks = self ._expanded_callbacks ,
98+ replacements = replacements ,
99+ ndid = ndid )
98100
99101 rd .layout = self .layout
100102
@@ -121,7 +123,7 @@ def expanded_callback(self, output, inputs=[], state=[], events=[]):
121123 self ._expanded_callbacks = True
122124 return self .callback (output , inputs , state , events )
123125
124- class NotFlask :
126+ class PseudoFlask :
125127 def __init__ (self ):
126128 self .config = {}
127129 self .endpoints = {}
@@ -138,21 +140,24 @@ def before_first_request(self,*args,**kwargs):
138140 def run (self ,* args ,** kwargs ):
139141 pass
140142
141- class NotDash (Dash ):
143+ class WrappedDash (Dash ):
142144 def __init__ (self , base_pathname = None , replacements = None , ndid = None , expanded_callbacks = False , ** kwargs ):
143145
144146 self ._uid = ndid
145147
146148 self ._flask_app = Flask (self ._uid )
147- self ._notflask = NotFlask ()
149+ self ._notflask = PseudoFlask ()
148150 self ._base_pathname = base_pathname
149151
150152 kwargs ['url_base_pathname' ] = self ._base_pathname
151153 kwargs ['server' ] = self ._notflask
152154
153- super (NotDash , self ).__init__ (** kwargs )
155+ super (WrappedDash , self ).__init__ (** kwargs )
154156
155157 self .css .config .serve_locally = True
158+ self .css .config .serve_locally = False
159+
160+ self .scripts .config .serve_locally = self .css .config .serve_locally
156161
157162 self ._adjust_id = False
158163 self ._dash_dispatch = not expanded_callbacks
@@ -270,10 +275,10 @@ def _fix_callback_item(self, item):
270275 return item
271276
272277 def callback (self , output , inputs = [], state = [], events = []):
273- return super (NotDash , self ).callback (self ._fix_callback_item (output ),
274- [self ._fix_callback_item (x ) for x in inputs ],
275- [self ._fix_callback_item (x ) for x in state ],
276- [self ._fix_callback_item (x ) for x in events ])
278+ return super (WrappedDash , self ).callback (self ._fix_callback_item (output ),
279+ [self ._fix_callback_item (x ) for x in inputs ],
280+ [self ._fix_callback_item (x ) for x in state ],
281+ [self ._fix_callback_item (x ) for x in events ])
277282
278283 def dispatch (self ):
279284 import flask
0 commit comments