本文整理汇总了Python中superset.connectors.connector_registry.ConnectorRegistry.get_all_datasources方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectorRegistry.get_all_datasources方法的具体用法?Python ConnectorRegistry.get_all_datasources怎么用?Python ConnectorRegistry.get_all_datasources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类superset.connectors.connector_registry.ConnectorRegistry
的用法示例。
在下文中一共展示了ConnectorRegistry.get_all_datasources方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_missing_perms
# 需要导入模块: from superset.connectors.connector_registry import ConnectorRegistry [as 别名]
# 或者: from superset.connectors.connector_registry.ConnectorRegistry import get_all_datasources [as 别名]
def create_missing_perms():
"""Creates missing perms for datasources, schemas and metrics"""
logging.info(
"Fetching a set of all perms to lookup which ones are missing")
all_pvs = set()
for pv in sm.get_session.query(sm.permissionview_model).all():
if pv.permission and pv.view_menu:
all_pvs.add((pv.permission.name, pv.view_menu.name))
def merge_pv(view_menu, perm):
"""Create permission view menu only if it doesn't exist"""
if view_menu and perm and (view_menu, perm) not in all_pvs:
merge_perm(sm, view_menu, perm)
logging.info("Creating missing datasource permissions.")
datasources = ConnectorRegistry.get_all_datasources(db.session)
for datasource in datasources:
merge_pv('datasource_access', datasource.get_perm())
merge_pv('schema_access', datasource.schema_perm)
logging.info("Creating missing database permissions.")
databases = db.session.query(models.Database).all()
for database in databases:
merge_pv('database_access', database.perm)
logging.info("Creating missing metrics permissions")
metrics = []
for datasource_class in ConnectorRegistry.sources.values():
metrics += list(db.session.query(datasource_class.metric_class).all())
for metric in metrics:
if (metric.is_restricted):
merge_pv('metric_access', metric.perm)
示例2: create_missing_datasource_perms
# 需要导入模块: from superset.connectors.connector_registry import ConnectorRegistry [as 别名]
# 或者: from superset.connectors.connector_registry.ConnectorRegistry import get_all_datasources [as 别名]
def create_missing_datasource_perms(view_menu_set):
logging.info("Creating missing datasource permissions.")
datasources = ConnectorRegistry.get_all_datasources(
db.session)
for datasource in datasources:
if datasource and datasource.perm not in view_menu_set:
merge_perm(sm, 'datasource_access', datasource.get_perm())
if datasource.schema_perm:
merge_perm(sm, 'schema_access', datasource.schema_perm)