Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Mar 7, 2017
1 parent 7cc71e3 commit 661e0fc
Show file tree
Hide file tree
Showing 22 changed files with 3,510 additions and 3,411 deletions.
8 changes: 4 additions & 4 deletions superset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from flask_appbuilder import SQLA, AppBuilder, IndexView
from flask_appbuilder.baseviews import expose
from flask_migrate import Migrate
from superset.source_registry import SourceRegistry
from superset.connectors.connector_registry import ConnectorRegistry
from werkzeug.contrib.fixers import ProxyFix
from superset import utils
from superset import utils, config # noqa


APP_DIR = os.path.dirname(__file__)
Expand Down Expand Up @@ -104,6 +104,6 @@ def index(self):
# Registering sources
module_datasource_map = app.config.get("DEFAULT_MODULE_DS_MAP")
module_datasource_map.update(app.config.get("ADDITIONAL_MODULE_DS_MAP"))
SourceRegistry.register_sources(module_datasource_map)
ConnectorRegistry.register_sources(module_datasource_map)

from superset import views, config # noqa
from superset import views # noqa
3 changes: 2 additions & 1 deletion superset/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from flask_migrate import MigrateCommand
from flask_script import Manager

from superset import app, db, data, security
from superset import app, db, security

config = app.config

Expand Down Expand Up @@ -89,6 +89,7 @@ def version(verbose):
help="Load additional test data")
def load_examples(load_test_data):
"""Loads a set of Slices and Dashboards and a supporting dataset """
from superset import data
print("Loading examples into {}".format(db))

data.load_css_templates()
Expand Down
5 changes: 4 additions & 1 deletion superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@
# --------------------------------------------------
# Modules, datasources and middleware to be registered
# --------------------------------------------------
DEFAULT_MODULE_DS_MAP = {'superset.models': ['DruidDatasource', 'SqlaTable']}
DEFAULT_MODULE_DS_MAP = {
'superset.connectors.druid.models': ['DruidDatasource'],
'superset.connectors.sqla.models': ['SqlaTable'],
}
ADDITIONAL_MODULE_DS_MAP = {}
ADDITIONAL_MIDDLEWARE = []

Expand Down
4 changes: 4 additions & 0 deletions superset/connectors/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import json

from superset import utils


class Datasource(object):

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sqlalchemy.orm import subqueryload


class SourceRegistry(object):
class ConnectorRegistry(object):
""" Central Registry for all available datasource engines"""

sources = {}
Expand All @@ -26,15 +26,15 @@ def get_datasource(cls, datasource_type, datasource_id, session):
@classmethod
def get_all_datasources(cls, session):
datasources = []
for source_type in SourceRegistry.sources:
for source_type in ConnectorRegistry.sources:
datasources.extend(
session.query(SourceRegistry.sources[source_type]).all())
session.query(ConnectorRegistry.sources[source_type]).all())
return datasources

@classmethod
def get_datasource_by_name(cls, session, datasource_type, datasource_name,
schema, database_name):
datasource_class = SourceRegistry.sources[datasource_type]
datasource_class = ConnectorRegistry.sources[datasource_type]
datasources = session.query(datasource_class).all()

# Filter datasoures that don't have database.
Expand All @@ -45,7 +45,7 @@ def get_datasource_by_name(cls, session, datasource_type, datasource_name,

@classmethod
def query_datasources_by_permissions(cls, session, database, permissions):
datasource_class = SourceRegistry.sources[database.type]
datasource_class = ConnectorRegistry.sources[database.type]
return (
session.query(datasource_class)
.filter_by(database_id=database.id)
Expand All @@ -56,7 +56,7 @@ def query_datasources_by_permissions(cls, session, database, permissions):
@classmethod
def get_eager_datasource(cls, session, datasource_type, datasource_id):
"""Returns datasource with columns and metrics."""
datasource_class = SourceRegistry.sources[datasource_type]
datasource_class = ConnectorRegistry.sources[datasource_type]
return (
session.query(datasource_class)
.options(
Expand Down
2 changes: 2 additions & 0 deletions superset/connectors/druid/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models # noqa
from . import views # noqa
Loading

0 comments on commit 661e0fc

Please sign in to comment.