Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support the Flask Extension API #738

Closed
multimeric opened this issue May 23, 2019 · 0 comments · Fixed by #739
Closed

[Feature Request] Support the Flask Extension API #738

multimeric opened this issue May 23, 2019 · 0 comments · Fixed by #739

Comments

@multimeric
Copy link
Contributor

multimeric commented May 23, 2019

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 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.

@multimeric multimeric changed the title [Feature Request] Flask Extension API [Feature Request] Support the Flask Extension API May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant