From cef96c6e67e4dc3334e1bc1c2924c88360ff9750 Mon Sep 17 00:00:00 2001 From: FFX01 Date: Thu, 16 Jul 2015 00:07:49 -0700 Subject: [PATCH] User not authenticated search fix When a user is not logged in and attempts to access the login page with debug mode enabled, the file "base.html" throws an exception claiming that "search_form" is not an attribute of the global "g" object. It appears this was being caused by "search_form" only being defined for "g" if the user is authenticated. Moved attribute declaration out of if clause. --- app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index 23125ca..36a8ddd 100644 --- a/app/views.py +++ b/app/views.py @@ -28,11 +28,11 @@ def get_locale(): @app.before_request def before_request(): g.user = current_user + g.search_form = SearchForm() if g.user.is_authenticated(): g.user.last_seen = datetime.utcnow() db.session.add(g.user) db.session.commit() - g.search_form = SearchForm() g.locale = get_locale()