@@ -72,17 +72,30 @@ def have_current_state_entry(self, wid, key):
7272 'Do nothing impl - only matters if state present'
7373 pass
7474
75- def form_dash_instance (self , replacements = None , specific_identifier = 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 )
78+ ndid = self ._uid
7879 else :
7980 app_pathname = "%s:%s" % (app_name , main_view_label )
81+ ndid = specific_identifier
82+
83+ try :
84+ full_url = reverse (app_pathname ,kwargs = {'id' :ndid })
85+ except :
86+ full_url = "/%s/" % ndid
87+
88+ return ndid , full_url
89+
90+ def form_dash_instance (self , replacements = None , specific_identifier = None ):
8091
81- rd = NotDash (name_root = self ._uid ,
82- app_pathname = app_pathname ,
92+ ndid , base_pathname = self .get_base_pathname (specific_identifier )
93+
94+ rd = NotDash (base_pathname = base_pathname ,
8395 expanded_callbacks = self ._expanded_callbacks ,
8496 replacements = replacements ,
85- specific_identifier = specific_identifier )
97+ ndid = ndid )
98+
8699 rd .layout = self .layout
87100
88101 for cb , func in self ._callback_sets :
@@ -126,22 +139,24 @@ def run(self,*args,**kwargs):
126139 pass
127140
128141class NotDash (Dash ):
129- def __init__ (self , name_root , app_pathname = None , replacements = None , specific_identifier = None , expanded_callbacks = False , ** kwargs ):
142+ def __init__ (self , base_pathname = None , replacements = None , ndid = None , expanded_callbacks = False , ** kwargs ):
130143
131- if specific_identifier is not None :
132- self ._uid = specific_identifier
133- else :
134- self ._uid = name_root
144+ self ._uid = ndid
135145
136146 self ._flask_app = Flask (self ._uid )
137147 self ._notflask = NotFlask ()
138- self ._base_pathname = reverse ( app_pathname , kwargs = { 'id' : self . _uid })
148+ self ._base_pathname = base_pathname
139149
140150 kwargs ['url_base_pathname' ] = self ._base_pathname
141151 kwargs ['server' ] = self ._notflask
142152
143153 super (NotDash , self ).__init__ (** kwargs )
144154
155+ self .css .config .serve_locally = True
156+ #self.css.config.serve_locally = False
157+
158+ self .scripts .config .serve_locally = self .css .config .serve_locally
159+
145160 self ._adjust_id = False
146161 self ._dash_dispatch = not expanded_callbacks
147162 if replacements :
@@ -158,17 +173,16 @@ def use_dash_layout(self):
158173
159174 def augment_initial_layout (self , base_response ):
160175 if self .use_dash_layout () and False :
161- return HttpResponse (base_response .data ,
162- content_type = base_response .mimetype )
176+ return base_response .data , base_response .mimetype
163177 # Adjust the base layout response
164178 baseDataInBytes = base_response .data
165179 baseData = json .loads (baseDataInBytes .decode ('utf-8' ))
166180 # Walk tree. If at any point we have an element whose id matches, then replace any named values at this level
167181 reworked_data = self .walk_tree_and_replace (baseData )
168182 response_data = json .dumps (reworked_data ,
169183 cls = PlotlyJSONEncoder )
170- return HttpResponse ( response_data ,
171- content_type = base_response .mimetype )
184+
185+ return response_data , base_response .mimetype
172186
173187 def walk_tree_and_extract (self , data , target ):
174188 if isinstance (data , dict ):
0 commit comments