@@ -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 ):
91+
92+ ndid , base_pathname = self .get_base_pathname (specific_identifier )
8093
81- rd = NotDash (name_root = self ._uid ,
82- app_pathname = app_pathname ,
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,21 @@ 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+
145157 self ._adjust_id = False
146158 self ._dash_dispatch = not expanded_callbacks
147159 if replacements :
@@ -158,17 +170,16 @@ def use_dash_layout(self):
158170
159171 def augment_initial_layout (self , base_response ):
160172 if self .use_dash_layout () and False :
161- return HttpResponse (base_response .data ,
162- content_type = base_response .mimetype )
173+ return base_response .data , base_response .mimetype
163174 # Adjust the base layout response
164175 baseDataInBytes = base_response .data
165176 baseData = json .loads (baseDataInBytes .decode ('utf-8' ))
166177 # Walk tree. If at any point we have an element whose id matches, then replace any named values at this level
167178 reworked_data = self .walk_tree_and_replace (baseData )
168179 response_data = json .dumps (reworked_data ,
169180 cls = PlotlyJSONEncoder )
170- return HttpResponse ( response_data ,
171- content_type = base_response .mimetype )
181+
182+ return response_data , base_response .mimetype
172183
173184 def walk_tree_and_extract (self , data , target ):
174185 if isinstance (data , dict ):
0 commit comments