You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described here, the average flask extension is an object that can be instantiated without access to the flask app, e.g. foo = Foo(), and then later is given access to the app using foo.init_app(app). This is required in situations where you are using the app factory pattern, where you only have access to the app inside the factory function, but you need to be able to define your extension outside this scope.
Proposed Changes
Fortunately, Dash almost meets those requirements. We just need:
To be able to instantiate an incomplete Dash app without passing it a Flask app. Currently if we try to do so, Dash will generate its own Flask app for us, which is not what we want in this situation. Thus I'm suggesting some syntax like dash = dash.Dash(defer=True), which would postpone most of the init logic until it has access to a Flask app
To be able to provide the flask app at a later time. For this, I propose the standard Flask extension syntax: dash.init_app(app), which gives dash a copy of the app, and lets it run any deferred init logic that it wasn't able to complete at creation time.
Relation to other Issues
This relates to #38, except that I'm trying to provide a pragmatic solution that would let Dash function as a flask extension, without requiring broad API changes.
The text was updated successfully, but these errors were encountered:
Motivation
As described here, the average flask extension is an object that can be instantiated without access to the flask app, e.g.
foo = Foo()
, and then later is given access to the app usingfoo.init_app(app)
. This is required in situations where you are using the app factory pattern, where you only have access to the app inside the factory function, but you need to be able to define your extension outside this scope.Proposed Changes
Fortunately, Dash almost meets those requirements. We just need:
dash = dash.Dash(defer=True)
, which would postpone most of the init logic until it has access to a Flask appdash.init_app(app)
, which gives dash a copy of the app, and lets it run any deferred init logic that it wasn't able to complete at creation time.Relation to other Issues
This relates to #38, except that I'm trying to provide a pragmatic solution that would let Dash function as a flask extension, without requiring broad API changes.
The text was updated successfully, but these errors were encountered: