Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 404 page crash #1201

Merged
merged 1 commit into from Jul 28, 2023
Merged

Fix 404 page crash #1201

merged 1 commit into from Jul 28, 2023

Conversation

zorun
Copy link
Collaborator

@zorun zorun commented Jul 28, 2023

The 404 page crashes when the user is logged in:

  File "/home/zorun/code/ihatemoney/ihatemoney/templates/404.html", line 1, in top-level template code
    {% extends "layout.html" %}
  File "/home/zorun/code/ihatemoney/ihatemoney/templates/layout.html", line 124, in top-level template code
    {{ g.logout_form.hidden_tag() }}
  File "/home/zorun/venv/py3-ihatemoney/lib/python3.9/site-packages/jinja2/environment.py", line 474, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'flask.ctx._AppCtxGlobals object' has no attribute 'logout_form'

This is because the logout form is defined by a URL processor, and this does not seem to apply for all pages.

To solve this, simply skip the logout form if it's not defined.

The 404 page crashes when the user is logged in:

      File "/home/zorun/code/ihatemoney/ihatemoney/templates/404.html", line 1, in top-level template code
        {% extends "layout.html" %}
      File "/home/zorun/code/ihatemoney/ihatemoney/templates/layout.html", line 124, in top-level template code
        {{ g.logout_form.hidden_tag() }}
      File "/home/zorun/venv/py3-ihatemoney/lib/python3.9/site-packages/jinja2/environment.py", line 474, in getattr
        return getattr(obj, attribute)
    jinja2.exceptions.UndefinedError: 'flask.ctx._AppCtxGlobals object' has no attribute 'logout_form'

This is because the logout form is defined by a URL processor, and this
does not seem to apply for all pages.

To solve this, simply skip the logout form if it's not defined.
@zorun zorun merged commit ad5b108 into master Jul 28, 2023
15 checks passed
@zorun zorun deleted the fix_404_crash branch July 28, 2023 15:20
@almet
Copy link
Member

almet commented Jul 28, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants