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


Python ConnectorRegistry.query_datasources_by_permissions方法代码示例

本文整理汇总了Python中superset.connectors.connector_registry.ConnectorRegistry.query_datasources_by_permissions方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectorRegistry.query_datasources_by_permissions方法的具体用法?Python ConnectorRegistry.query_datasources_by_permissions怎么用?Python ConnectorRegistry.query_datasources_by_permissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在superset.connectors.connector_registry.ConnectorRegistry的用法示例。


在下文中一共展示了ConnectorRegistry.query_datasources_by_permissions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: accessible_by_user

# 需要导入模块: from superset.connectors.connector_registry import ConnectorRegistry [as 别名]
# 或者: from superset.connectors.connector_registry.ConnectorRegistry import query_datasources_by_permissions [as 别名]
    def accessible_by_user(self, database, datasource_names, schema=None):
        if self.database_access(database) or self.all_datasource_access():
            return datasource_names

        if schema:
            schema_perm = utils.get_schema_perm(database, schema)
            if self.can_access('schema_access', schema_perm):
                return datasource_names

        user_perms = self.user_datasource_perms()
        user_datasources = ConnectorRegistry.query_datasources_by_permissions(
            db.session, database, user_perms)
        if schema:
            names = {
                d.table_name
                for d in user_datasources if d.schema == schema}
            return [d for d in datasource_names if d in names]
        else:
            full_names = {d.full_name for d in user_datasources}
            return [d for d in datasource_names if d in full_names]
开发者ID:herotan24,项目名称:incubator-superset,代码行数:22,代码来源:base.py

示例2: accessible_by_user

# 需要导入模块: from superset.connectors.connector_registry import ConnectorRegistry [as 别名]
# 或者: from superset.connectors.connector_registry.ConnectorRegistry import query_datasources_by_permissions [as 别名]
    def accessible_by_user(self, database, datasource_names, schema=None):
        if self.database_access(database) or self.all_datasource_access():
            return datasource_names

        schema_perm = utils.get_schema_perm(database, schema)
        if schema and utils.can_access(
                sm, 'schema_access', schema_perm, g.user):
            return datasource_names

        role_ids = set([role.id for role in g.user.roles])
        # TODO: cache user_perms or user_datasources
        user_pvms = (
            db.session.query(ab_models.PermissionView)
            .join(ab_models.Permission)
            .filter(ab_models.Permission.name == 'datasource_access')
            .filter(ab_models.PermissionView.role.any(
                ab_models.Role.id.in_(role_ids)))
            .all()
        )
        user_perms = set([pvm.view_menu.name for pvm in user_pvms])
        user_datasources = ConnectorRegistry.query_datasources_by_permissions(
            db.session, database, user_perms)
        full_names = set([d.full_name for d in user_datasources])
        return [d for d in datasource_names if d in full_names]
开发者ID:dawsongzhao,项目名称:superset,代码行数:26,代码来源:base.py


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