Merge lp:~gz/python-oops-tools/error_templates into lp:python-oops-tools

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: 35
Merged at revision: 35
Proposed branch: lp:~gz/python-oops-tools/error_templates
Merge into: lp:python-oops-tools
Diff against target: 38 lines (+24/-0)
3 files modified
src/oopstools/oops/templates/404.html (+5/-0)
src/oopstools/oops/templates/500.html (+5/-0)
src/oopstools/oops/templates/error.html (+14/-0)
To merge this branch: bzr merge lp:~gz/python-oops-tools/error_templates
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+116031@code.launchpad.net

Commit message

Show an error page rather than creating an oops for unknown locations

Description of the change

Currently going to <https://oops.canonical.com/somethingnonexistant> results not in a 404 as expected but an oops. Which is a little cute, but is also the only fault currently reported with the service in the daily emails.

This branch adds trivial templates for the default 404 and 500 handlers so a client gets a (semi) meaningful response rather than a knock-on failure.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This seems fine for what it is. I am curious why the 404 and 500 views
built into django were not being used.

Since these added views aren't all that fancy I would think the defaults
would work fine, if we knew how to activate them.

review: Approve (code)
Revision history for this message
Martin Packman (gz) wrote :

Thanks for the review Benji.

As just creating the templates worked, was happy to not try and understand the django magic beneath. If there's someone you can suggest I poke to look at that, I shall do so.

Revision history for this message
Benji York (benji) wrote :

On Tue, Jul 24, 2012 at 9:40 AM, Martin Packman
<email address hidden> wrote:
> As just creating the templates worked, was happy to not try and
> understand the django magic beneath.

I can understand that. I don't understand it either. In fact, I think
this is the first "django code" I have ever read. It seemed like
something that django should do for us so found this documentation:

https://docs.djangoproject.com/en/dev/topics/http/views/#the-404-page-not-found-view

> If there's someone you can
> suggest I poke to look at that, I shall do so.

I think MAAS uses django heavily, maybe one of the people that have
worked on it could help without too much effort.
--
Benji York

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'src/oopstools/oops/templates/404.html'
--- src/oopstools/oops/templates/404.html 1970-01-01 00:00:00 +0000
+++ src/oopstools/oops/templates/404.html 2012-07-20 16:45:44 +0000
@@ -0,0 +1,5 @@
1{% extends "error.html" %}
2
3{% block title %}404{% endblock %}
4
5{% block description %}No resource at {{request_path}} found.{% endblock %}
06
=== added file 'src/oopstools/oops/templates/500.html'
--- src/oopstools/oops/templates/500.html 1970-01-01 00:00:00 +0000
+++ src/oopstools/oops/templates/500.html 2012-07-20 16:45:44 +0000
@@ -0,0 +1,5 @@
1{% extends "error.html" %}
2
3{% block title %}500{% endblock %}
4
5{% block description %}An internal server error occurred.{% endblock %}
06
=== added file 'src/oopstools/oops/templates/error.html'
--- src/oopstools/oops/templates/error.html 1970-01-01 00:00:00 +0000
+++ src/oopstools/oops/templates/error.html 2012-07-20 16:45:44 +0000
@@ -0,0 +1,14 @@
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <title>Error</title>
6 <style type="text/css" media="screen">
7 @import url("/oops/static/oops.css");
8 </style>
9 </head>
10 <body>
11 <h1>{% block title %}{% endblock %}!</h1>
12 <p>{% block description %}An unknown error occurred.{% endblock %}</p>
13 </body>
14</html>

Subscribers

People subscribed via source and target branches

to all changes: