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
=== modified file 'wikkid/view/base.py'
--- wikkid/view/base.py 2010-06-23 10:57:14 +0000
+++ wikkid/view/base.py 2010-11-21 01:44:57 +0000
@@ -110,7 +110,15 @@
110 template = skin.get_template(self.template)110 template = skin.get_template(self.template)
111 content = template.render(**self.template_args())111 content = template.render(**self.template_args())
112 # Return the encoded content.112 # Return the encoded content.
113 return Response(content.encode('utf-8'))113 return self.make_response(content.encode('utf-8'))
114
115 def make_response(self, body):
116 """Construct the response object for this request.
117
118 :param body: The body of the response, as a unicode string.
119 :return: A `Response` object.
120 """
121 return Response(body)
114122
115 def render(self, skin):123 def render(self, skin):
116 """Render the page.124 """Render the page.
117125
=== modified file 'wikkid/view/missing.py'
--- wikkid/view/missing.py 2010-05-19 10:00:43 +0000
+++ wikkid/view/missing.py 2010-11-21 01:44:57 +0000
@@ -20,6 +20,11 @@
20 is_default = True20 is_default = True
21 template = 'missing'21 template = 'missing'
2222
23 def make_response(self, body):
24 response = super(BaseView, self).make_response(body)
25 response.status = "404 Not Found"
26 return response
27
23 @property28 @property
24 def content(self):29 def content(self):
25 '%s Not found' % self.path30 '%s Not found' % self.path

Subscribers

People subscribed via source and target branches