本文整理汇总了Python中core.db.connection.DataHubConnection.remove_user方法的典型用法代码示例。如果您正苦于以下问题:Python DataHubConnection.remove_user方法的具体用法?Python DataHubConnection.remove_user怎么用?Python DataHubConnection.remove_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.db.connection.DataHubConnection
的用法示例。
在下文中一共展示了DataHubConnection.remove_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_app
# 需要导入模块: from core.db.connection import DataHubConnection [as 别名]
# 或者: from core.db.connection.DataHubConnection import remove_user [as 别名]
def remove_app(app_id):
app = App.objects.get(app_id=app_id)
app.delete()
superuser_con = DataHubConnection(
user=settings.DATABASES['default']['USER'],
password=settings.DATABASES['default']['USER'])
superuser_con.remove_user(username=app_id)
示例2: remove_user
# 需要导入模块: from core.db.connection import DataHubConnection [as 别名]
# 或者: from core.db.connection.DataHubConnection import remove_user [as 别名]
def remove_user(username, remove_db=True):
# get the user associated with the username, and delete their apps
try:
user = User.objects.get(username=username)
apps = App.objects.filter(user=user)
for app in apps:
app_id = app.app_id
DataHubManager.remove_app(app_id=app_id)
Collaborator.objects.filter(user=user).delete()
except:
user = None
# do the same thing for legacy users
try:
legacy_user = DataHubLegacyUser.objects.get(username=username)
apps = App.objects.filter(legacy_user=legacy_user)
for app in apps:
app_id = app.app_id
DataHubManager.remove_app(app_id=app_id)
except:
legacy_user = None
# delete the users
if user:
user.delete()
if legacy_user:
legacy_user.delete()
# delete the user's db
if remove_db:
DataHubManager.remove_database(username)
# make a connection, and delete the user's database account
superuser_con = DataHubConnection(
user=settings.DATABASES['default']['USER'],
password=settings.DATABASES['default']['USER'])
try:
return superuser_con.remove_user(username=username)
except:
all_db_list = DataHubManager.list_all_databases()
for db in all_db_list:
DataHubManager.drop_owned_by(username=username, repo_base=db)
return superuser_con.remove_user(username=username)
示例3: remove_user
# 需要导入模块: from core.db.connection import DataHubConnection [as 别名]
# 或者: from core.db.connection.DataHubConnection import remove_user [as 别名]
def remove_user(username):
superuser_con = DataHubConnection(
user=settings.DATABASES['default']['USER'],
password=settings.DATABASES['default']['USER'])
return superuser_con.remove_user(username=username)
示例4: remove_user
# 需要导入模块: from core.db.connection import DataHubConnection [as 别名]
# 或者: from core.db.connection.DataHubConnection import remove_user [as 别名]
def remove_user(username):
superuser_con = DataHubConnection(
user=settings.DATABASES["default"]["USER"], password=settings.DATABASES["default"]["USER"]
)
return superuser_con.remove_user(username=username)