当前位置: 首页>>代码示例>>Python>>正文


Python ConnectorRegistry.get_all_datasources方法代码示例

本文整理汇总了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)
开发者ID:invenis-paris,项目名称:incubator-superset,代码行数:36,代码来源:security.py

示例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)
开发者ID:avsolatorio,项目名称:caravel,代码行数:11,代码来源:security.py


注:本文中的superset.connectors.connector_registry.ConnectorRegistry.get_all_datasources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。