本文整理汇总了Python中core.db.connection.DataHubConnection.get_view_sql方法的典型用法代码示例。如果您正苦于以下问题:Python DataHubConnection.get_view_sql方法的具体用法?Python DataHubConnection.get_view_sql怎么用?Python DataHubConnection.get_view_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.db.connection.DataHubConnection
的用法示例。
在下文中一共展示了DataHubConnection.get_view_sql方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from core.db.connection import DataHubConnection [as 别名]
# 或者: from core.db.connection.DataHubConnection import get_view_sql [as 别名]
#.........这里部分代码省略.........
Raises LookupError when repo or collaborator does not exist.
Raises User.DoesNotExist if collaborator owns repo.
Raises PermissionDenied on insufficient permissions.
"""
with _superuser_connection(self.repo_base) as conn:
collaborators = conn.list_collaborators(repo=repo)
collaborators = [c.get('username') for c in collaborators]
# Current user must be the repo's owner or the collaborator to be
# removed and must be an existing collaborator. If not the owner
# and removing someone else, current user must have CREATE db
# privileges.
if (self.username not in [collaborator, self.repo_base] or
self.username not in collaborators):
DataHubManager.has_repo_db_privilege(
self.username, self.repo_base, repo, 'CREATE')
# The reason we're enforcing permission checks this way is to deal
# with the edge case where a user removes himself as a collaborator
# from another user's repo.
if collaborator not in collaborators:
raise LookupError('Failed to delete collaborator.'
' %s is not a collaborator in the specified '
'repository.' % collaborator)
collab = User.objects.get(username=collaborator)
Collaborator.objects.get(
user=collab, repo_name=repo, repo_base=self.repo_base).delete()
result = conn.delete_collaborator(
repo=repo, collaborator=collaborator)
return result
def create_license_view(self, repo, table, view_params, license_id):
view_sql = self.user_con.get_view_sql(
repo_base=self.repo_base,
repo=repo,
table=table,
view_params=view_params,
license_id=license_id)
license_id = int(license_id)
license_view_obj, created = LicenseView.objects.get_or_create(
repo_base=self.repo_base,
repo_name=repo,
table=table,
view_sql=view_sql,
license_id=license_id)
# Create view in database
self.user_con.create_license_view(
repo_base=self.repo_base,
repo=repo,
table=table,
view_sql=view_sql,
license_id=license_id)
return True
def delete_license_view(self, repo, table, license_view, license_id):
license_view_obj = LicenseView.objects.filter(
repo_base=self.repo_base,
repo_name=repo,
table=table,
license_id=license_id)
if len(license_view_obj) == 1: