From baa60e0ae0513e70aa52737bf6059f2043c539bc Mon Sep 17 00:00:00 2001 From: Muriithi Frederick Muriuki Date: Wed, 21 Feb 2018 11:46:52 +0300 Subject: Fix assumption of existing collection * When logging in, if a user selects "Import existing collections", the system would throw an exception, since Redis would return a NoneType, which would then be accessed by json.loads(), which doesn't seem to know how to process that. This fixes that, by providing a string representing an empty json array ("[]"), in place of the NoneType. --- wqflask/wqflask/user_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index fd1d56ff..e1920f4e 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -122,7 +122,8 @@ class AnonUser(object): return collections def import_traits_to_user(self): - collections_list = json.loads(Redis.get(self.key)) + result = Redis.get(self.key) + collections_list = json.loads(result if result else "[]") for collection in collections_list: uc = model.UserCollection() uc.name = collection['name'] -- cgit v1.2.3