Merge lp:~mwhudson/wikkid/missing-404 into lp:wikkid

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Tim Penhey
Approved revision: 53
Merged at revision: 54
Proposed branch: lp:~mwhudson/wikkid/missing-404
Merge into: lp:wikkid
Diff against target: 36 lines (+14/-1)
2 files modified
wikkid/view/base.py (+9/-1)
wikkid/view/missing.py (+5/-0)
To merge this branch: bzr merge lp:~mwhudson/wikkid/missing-404
Reviewer Review Type Date Requested Status
Tim Penhey Approve
Review via email: mp+41407@code.launchpad.net

Description of the change

This branch makes missing pages 404s at the http level.

I add an extension point to the base view to allow the response creation to be customized by a view. There were many things that would have been sufficient for what I needed here, so I went for something pretty simple.

No tests, because the missing and base views doesn't seem to be tested at all. Happy to be corrected if I've missed them, or write some!

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

I've taken this and tweaked it slightly. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'wikkid/view/base.py'
2--- wikkid/view/base.py 2010-06-23 10:57:14 +0000
3+++ wikkid/view/base.py 2010-11-21 01:44:57 +0000
4@@ -110,7 +110,15 @@
5 template = skin.get_template(self.template)
6 content = template.render(**self.template_args())
7 # Return the encoded content.
8- return Response(content.encode('utf-8'))
9+ return self.make_response(content.encode('utf-8'))
10+
11+ def make_response(self, body):
12+ """Construct the response object for this request.
13+
14+ :param body: The body of the response, as a unicode string.
15+ :return: A `Response` object.
16+ """
17+ return Response(body)
18
19 def render(self, skin):
20 """Render the page.
21
22=== modified file 'wikkid/view/missing.py'
23--- wikkid/view/missing.py 2010-05-19 10:00:43 +0000
24+++ wikkid/view/missing.py 2010-11-21 01:44:57 +0000
25@@ -20,6 +20,11 @@
26 is_default = True
27 template = 'missing'
28
29+ def make_response(self, body):
30+ response = super(BaseView, self).make_response(body)
31+ response.status = "404 Not Found"
32+ return response
33+
34 @property
35 def content(self):
36 '%s Not found' % self.path

Subscribers

People subscribed via source and target branches