Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Make the package a Flask extention so it can be used with init_app #24

Copy link
Copy link
@sergioisidoro

Description

@sergioisidoro
Issue body actions

When making modular flask applications, it's common not to immediately provide the app in the constructor, but to pass it later on with the method init_app(app) as we can see in the documentation -- https://flask.palletsprojects.com/en/1.1.x/extensions/

With a bit of changes on the constructor this can become a "proper" flask extension
https://flask.palletsprojects.com/en/1.1.x/extensiondev/

The example of the SQLite extension provides an idea on how this could look like:

    def __init__(self, app=None):
        self.app = app
        if app is not None:
            self.init_app(app)

    def init_app(self, app):
        app.config.setdefault('SQLITE3_DATABASE', ':memory:')
        app.teardown_appcontext(self.teardown)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.