From 8c6d6c63460dd29e416887ccc55ad32768f9a4e4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 1 Oct 2018 14:10:43 +0200 Subject: [PATCH 1/2] use a much simpler errorpage.html template, related to #356 #365 the normal base template does quite a lot of stuff and the context / session needs to be prepared for that. in case of errors, we do not want to do any heavy stuff, like accessing the db / session. --- nsupdate/templates/errorpage.html | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/nsupdate/templates/errorpage.html b/nsupdate/templates/errorpage.html index 92f0da4..3a9a20f 100644 --- a/nsupdate/templates/errorpage.html +++ b/nsupdate/templates/errorpage.html @@ -1,10 +1,14 @@ -{% extends "base.html" %} -{% load i18n %}{% load bootstrap %} + + + + + {{ WWW_HOST }} - something went wrong... + + -{% block content %} -
- {% block error %} - {% endblock %} -
-{% endblock %} + {% block error %} + {% endblock %} + Back to {{ WWW_HOST }}. + + From bc9776b1199d212a2a7e65d02844d65d5a45077e Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 1 Oct 2018 15:06:01 +0200 Subject: [PATCH 2/2] no exceptions when context processor saves the session, fixes #356 --- nsupdate/context_processors.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nsupdate/context_processors.py b/nsupdate/context_processors.py index acf022f..948b38d 100644 --- a/nsupdate/context_processors.py +++ b/nsupdate/context_processors.py @@ -13,6 +13,7 @@ from .main.dnstools import put_ip_into_session from .main.iptools import normalize_ip from django.conf import settings +from django.db import OperationalError MAX_IP_AGE = 180 # seconds @@ -63,5 +64,11 @@ def update_ips(request): # if we have a new session (== not loaded from database / storage), we # MUST save it here to create its session_key as the base.html template # uses .session_key to build the URL for detectip: - s.save() + try: + s.save() + except OperationalError: + # if e.g. the database is locked (sqlite), do not blow up here, + # because it gives rather ugly tracebacks in the email even if django + # was just rendering the 404 template for the current request, see #356. + pass return {}