本文整理匯總了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: