diff options
Diffstat (limited to 'wqflask/utility/redis_tools.py')
-rw-r--r-- | wqflask/utility/redis_tools.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/wqflask/utility/redis_tools.py b/wqflask/utility/redis_tools.py index 236cc755..ff125bd2 100644 --- a/wqflask/utility/redis_tools.py +++ b/wqflask/utility/redis_tools.py @@ -26,7 +26,9 @@ def is_redis_available(): def load_json_from_redis(item_list, column_value): - return json.loads(item_list[str.encode(column_value)]) + if type(column_value) == str: + column_value = str.encode(column_value) + return json.loads(item_list[column_value]) def get_user_id(column_name, column_value): @@ -133,8 +135,10 @@ def get_user_groups(user_id): for key in groups_list: try: group_ob = json.loads(groups_list[key]) - group_admins = set(group_ob['admins']) - group_members = set(group_ob['members']) + group_admins = set([this_admin.encode( + 'utf-8') if this_admin else None for this_admin in group_ob['admins']]) + group_members = set([this_member.encode( + 'utf-8') if this_member else None for this_member in group_ob['members']]) if user_id in group_admins: admin_group_ids.append(group_ob['id']) elif user_id in group_members: @@ -203,7 +207,8 @@ def get_groups_like_unique_column(column_name, column_value): if column_value in group_info[column_name]: matched_groups.append(group_info) else: - matched_groups.append(load_json_from_redis(group_list, column_value)) + matched_groups.append( + load_json_from_redis(group_list, column_value)) return matched_groups |