本文整理汇总了Python中database.DatabaseManager.delete_list方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.delete_list方法的具体用法?Python DatabaseManager.delete_list怎么用?Python DatabaseManager.delete_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.delete_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_list
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import delete_list [as 别名]
def delete_list():
db_manager = DatabaseManager()
username = request.json.get("username").lower()
listname = request.json.get("listname")
token = request.json.get("token")
if username == None or listname == None or token == None:
abort(400)
# Verifiy token
token_credentials = db_manager.verify_auth_token(token=token)
if token_credentials is None:
abort(401)
elif not db_manager.check_password(token_credentials[0], token_credentials[1]):
abort(401)
elif token_credentials[0] != username:
abort(401)
if not db_manager.listname_exists_for_user(username, listname):
return response_cache_header("No list found", cache_control="no-cache")
if db_manager.listname_exists_for_user(username, listname):
db_manager.delete_list(username, listname)
return response_cache_header(json.dumps({"response": "Successfully deleted list"}), cache_control="no-cache")
return abort(401)
示例2: delete_list
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import delete_list [as 别名]
def delete_list():
db_manager = DatabaseManager()
username = request.json.get('username')
listname = request.json.get('listname')
token = request.json.get('token')
if username == None or listname == None or token == None:
abort(400)
# Verifiy token
token_credentials = db_manager.verify_auth_token(token=token)
if token_credentials is None:
return json.dumps({ 'username':'ERROR, No user' })
elif not db_manager.check_password(token_credentials[0], token_credentials[1]):
return json.dumps({ 'username':'ERROR, Wrong token'})
elif token_credentials[0] != username:
abort(401)
if not db_manager.listname_exists_for_user(username, listname):
return "No list found"
if db_manager.listname_exists_for_user(username, listname):
db_manager.delete_list(username, listname)
return "Successfully deleted list"
return abort(401)
示例3: save_list
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import delete_list [as 别名]
def save_list():
db_manager = DatabaseManager()
username = request.json.get('username')
list_data = request.json.get('list_data')
token = request.json.get('token')
if username == None or list_data == None or token == None:
abort(400)
# Verifiy token
token_credentials = db_manager.verify_auth_token(token=token)
if token_credentials is None:
abort(401)
elif not db_manager.check_password(token_credentials[0], token_credentials[1]):
abort(401)
elif token_credentials[0] != username:
abort(401)
if list_data.get('listname') is None or list_data.get('language_1_tag') is None or list_data.get('language_2_tag') is None or list_data.get('shared_with') is None:
abort(400)
if list_data.get('listname') is "" or list_data.get('language_1_tag') is "" or list_data.get('language_2_tag') is "" or list_data.get('shared_with') is "":
abort(400)
if db_manager.listname_exists_for_user(username, list_data.get('listname')):
db_manager.delete_list(username, list_data.get('listname'))
db_manager.create_list(username, list_data.get('listname'), list_data.get('language_1_tag'), list_data.get('language_2_tag'), list_data.get('shared_with'))
words = list_data.get('words')
for i in range(len(words)):
word = words[i]
if word.get('language_1_text') is u'' or word.get('language_2_text') is u'':
continue
db_manager.create_translation(username, list_data.get('listname'), word.get('language_1_text'), word.get('language_2_text'))
return response_cache_header("Saved list", cache_control="no-cache")
示例4: save_list
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import delete_list [as 别名]
def save_list():
db_manager = DatabaseManager()
username = request.json.get("username").lower()
list_data = request.json.get("list_data")
token = request.json.get("token")
if username == None or list_data == None or token == None:
abort(400)
# Verifiy token
token_credentials = db_manager.verify_auth_token(token=token)
if token_credentials is None:
abort(401)
elif not db_manager.check_password(token_credentials[0], token_credentials[1]):
abort(401)
elif token_credentials[0] != username:
abort(401)
if len(list_data.get("listname")) > 20:
print(list_data["listname"][:20])
list_data["listname"] = list_data["listname"][:20]
if (
list_data.get("listname") is None
or list_data.get("language_1_tag") is None
or list_data.get("language_2_tag") is None
or list_data.get("shared_with") is None
):
abort(400)
if (
list_data.get("listname") is ""
or list_data.get("language_1_tag") is ""
or list_data.get("language_2_tag") is ""
or list_data.get("shared_with") is ""
):
abort(400)
if db_manager.listname_exists_for_user(username, list_data.get("listname")):
old_list = db_manager.get_list(username, list_data["listname"])
old_words = db_manager.get_translations_for_list(username, list_data["listname"])
db_manager.delete_list(username, list_data.get("listname"))
db_manager.create_list(
username,
list_data.get("listname"),
list_data.get("language_1_tag"),
list_data.get("language_2_tag"),
list_data.get("shared_with"),
)
words = list_data.get("words")
for i in range(len(words)):
word = words[i]
if word.get("language_1_text") is u"" or word.get("language_2_text") is u"":
continue
db_manager.create_translation(
username, list_data.get("listname"), word.get("language_1_text"), word.get("language_2_text")
)
return response_cache_header(
json.dumps({"response": "List exists", "old_list": old_list, "old_words": old_words}),
cache_control="no-cache",
)
db_manager.create_list(
username,
list_data.get("listname"),
list_data.get("language_1_tag"),
list_data.get("language_2_tag"),
list_data.get("shared_with"),
)
words = list_data.get("words")
for i in range(len(words)):
word = words[i]
if word.get("language_1_text") is u"" or word.get("language_2_text") is u"":
continue
db_manager.create_translation(
username, list_data.get("listname"), word.get("language_1_text"), word.get("language_2_text")
)
return response_cache_header(
json.dumps({"response": "Saved list!", "listname": list_data.get("listname")}), cache_control="no-cache"
)