-
Notifications
You must be signed in to change notification settings - Fork 150
flask-script should support init_app() pattern #122
Comments
Pleaseee! |
+1 |
1 similar comment
👍 |
I would love to see this |
I don't think flask-script should do that. The The steps
Step three is definitely not the use case of
|
If you are using the application factory pattern, most probably you will have this extension instantiated in a dedicated module. Just for this pattern, it is useful to be able to call the |
I'm with @lukasjuhrich on this one. Plus, overloading the A beginner to flask-script would probably get hung up trying to do something like this def create_app(config):
....
pages.init_app(app)
bootstrap.init_app(app)
manager.init_app(app)
...
return app which would be incorrect since the proposal is to have Please correct me if I've misunderstood the original intent behind this issue, this was how I interpreted it. I also recently found out that you actually can, in fact, delay the creation of the from app import create_app
manager = Manager(create_app)
manager.add_option('-c', '--config', dest='config', required=False)
...
manager.run() |
app = create_app(config_name)
...
...
manager.app = app should do the trick |
It would be really handy instead of requiring the flask "App" object at manager creation time, if this could be deferred until later, by using the init_app() pattern.
http://flask.pocoo.org/docs/0.10/patterns/appfactories/
The basic would be any
add_*
command, or something which registers would check if self.app is None, and if it is, you add it to a list. Thenmanager.init_app(app)
would go through each list and actually do the registration.The text was updated successfully, but these errors were encountered: