From c95e33831ca810400323dfe8f0e934112e658517 Mon Sep 17 00:00:00 2001 From: TLSM Date: Sat, 15 Oct 2022 07:23:29 -0400 Subject: [PATCH] Check for globals in calc_users; fix error pages. --- files/helpers/wrappers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 6bd5672a8..3f2466108 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -9,6 +9,10 @@ import user_agents import time def calc_users(v): + # Some globals we expect aren't available when rendering error pages + if not g.agent or not ('session_id' in session): + return '' + loggedin = cache.get(f'{SITE}_loggedin') or {} loggedout = cache.get(f'{SITE}_loggedout') or {} timestamp = int(time.time())