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

Add a Redash extension system based on Python entrypoints. #2354

Merged
merged 1 commit into from
Mar 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions redash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def to_url(self, value):


def create_app(load_admin=True):
from redash import handlers
from redash import extensions, handlers
from redash.handlers.webpack import configure_webpack
from redash.admin import init_admin
from redash.models import db
Expand Down Expand Up @@ -137,5 +137,5 @@ def create_app(load_admin=True):
limiter.init_app(app)
handlers.init_app(app)
configure_webpack(app)

extensions.init_extensions(app)
return app
14 changes: 14 additions & 0 deletions redash/extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pkg_resources import iter_entry_points


def init_extensions(app):
"""
Load the Redash extensions for the given Redash Flask app.
"""
if not hasattr(app, 'redash_extensions'):
app.redash_extensions = {}

for entry_point in iter_entry_points('redash.extensions'):
app.logger.info('Loading Redash extension %s.', entry_point.name)
extension = entry_point.load()
app.redash_extensions[entry_point.name] = extension(app)