Download:
child 42:06c224e8b052
parent 40:8f08809cc1ce
41:8d6436a284d2
Anton Shestakov <av6@dwimlabs.net>, Sun, 19 Jun 2016 00:18:30 +0800
viewer: inherit from BaseHandler for catch-all 404 pages too

2 файлов изменено, 8 вставок(+), 0 удалений(-) [+]
tests/test_viewer.py file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- a/tests/test_viewer.py Sun Jun 19 00:04:48 2016 +0800
+++ b/tests/test_viewer.py Sun Jun 19 00:18:30 2016 +0800
@@ -21,7 +21,9 @@
def test_index(self):
response = self.fetch('/')
assert response.code == 200
+ assert 'online linter' in response.body
def test_404(self):
response = self.fetch('/nobodyhere')
assert response.code == 404
+ assert 'online linter' in response.body
--- a/viewer.py Sun Jun 19 00:04:48 2016 +0800
+++ b/viewer.py Sun Jun 19 00:18:30 2016 +0800
@@ -10,6 +10,7 @@
from tornado.ioloop import IOLoop
from tornado.options import define, options
from tornado.web import Application, HTTPError, RequestHandler, URLSpec
+from tornado.web import ErrorHandler as BaseErrorHandler
from candolint import uimodules
from candolint.models import database, Project, Change, Check
@@ -126,6 +127,10 @@
self.render('status.svg', width=width, parts=parts, height=20)
+class ErrorHandler(BaseHandler, BaseErrorHandler):
+ pass
+
+
class CandolintViewer(Application):
def __init__(self):
handlers = [
@@ -133,6 +138,7 @@
URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)', ProjectHandler),
URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)/([\d]+|latest)', CheckHandler),
URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)/status\.svg', StatusHandler),
+ URLSpec(r'.*', ErrorHandler, {'status_code': 404})
]
settings = dict(
static_path=rel('static'),