changeset 5edb34b484c3 in www.tryton.org:default
details: https://hg.tryton.org/www.tryton.org?cmd=changeset;node=5edb34b484c3
description:
        Returns Not Found when template is… not found
diffstat:

 app.py |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r ffacabc4b1b1 -r 5edb34b484c3 app.py
--- a/app.py    Mon May 13 10:40:26 2019 +0200
+++ b/app.py    Tue May 14 10:30:39 2019 +0200
@@ -4,14 +4,16 @@
 
 from collections import namedtuple, OrderedDict
 from functools import partial
+from http import HTTPStatus
 from logging.handlers import SMTPHandler
 from random import shuffle
 from urllib.parse import urlparse
 
 import requests
 from flask import (Flask, render_template, redirect, url_for, request,
-    make_response)
+    make_response, abort)
 from flask.logging import default_handler
+from flask.templating import TemplateNotFound
 from flask_caching import Cache
 from flask_gravatar import Gravatar
 from flask_rev import Rev
@@ -276,7 +278,10 @@
 @app.route('/success-stories/<story>')
 @cache.cached()
 def success_story(story):
-    return render_template('success_stories/%s.html' % story)
+    try:
+        return render_template('success_stories/%s.html' % story)
+    except TemplateNotFound:
+        abort(HTTPStatus.NOT_FOUND)
 
 
 @app.route('/download')
@@ -345,7 +350,10 @@
             self.gravatar = gravatar
             self.company = company
             self.url = url
-    return render_template('events/%s.html' % event, Day=Day)
+    try:
+        return render_template('events/%s.html' % event, Day=Day)
+    except TemplateNotFound:
+        abort(HTTPStatus.NOT_FOUND)
 
 
 @app.route('/contribute')

Reply via email to