44import json
55
66from .models import DashApp
7- from .dash_wrapper import get_stateless_by_name
87
98def routes (* args ,** kwargs ):
109 raise NotImplementedError
1110
1211def dependencies (request , id , stateless = False , ** kwargs ):
13- if stateless :
14- da = get_stateless_by_name (id )
15- else :
16- da = get_object_or_404 (DashApp ,slug = id )
17-
18- app = da .as_dash_instance ()
12+ da , app = DashApp .locate_item (id , stateless )
1913
2014 with app .app_context ():
2115 mFunc = app .locate_endpoint_function ('dash-dependencies' )
@@ -24,22 +18,14 @@ def dependencies(request, id, stateless=False, **kwargs):
2418 content_type = resp .mimetype )
2519
2620def layout (request , id , stateless = False , ** kwargs ):
27- if stateless :
28- da = get_stateless_by_name (id )
29- else :
30- da = get_object_or_404 (DashApp ,slug = id )
31- app = da .as_dash_instance ()
21+ da , app = DashApp .locate_item (id , stateless )
3222
3323 mFunc = app .locate_endpoint_function ('dash-layout' )
3424 resp = mFunc ()
3525 return app .augment_initial_layout (resp )
3626
3727def update (request , id , stateless = False , ** kwargs ):
38- if stateless :
39- da = get_stateless_by_name (id )
40- else :
41- da = get_object_or_404 (DashApp ,slug = id )
42- app = da .as_dash_instance ()
28+ da , app = DashApp .locate_item (id , stateless )
4329
4430 rb = json .loads (request .body .decode ('utf-8' ))
4531
@@ -62,11 +48,7 @@ def update(request, id, stateless=False, **kwargs):
6248 content_type = resp .mimetype )
6349
6450def main_view (request , id , stateless = False , ** kwargs ):
65- if stateless :
66- da = get_stateless_by_name (id )
67- else :
68- da = get_object_or_404 (DashApp ,slug = id )
69- app = da .as_dash_instance ()
51+ da , app = DashApp .locate_item (id , stateless )
7052
7153 mFunc = app .locate_endpoint_function ()
7254 resp = mFunc ()
0 commit comments