changeset 73:12ee37017538

introduce templated 404s; works, just doesnt do anything yet
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 23 Aug 2012 23:19:07 -0700
parents 32d7286adfa5
children dd7d385e11ea
files decoupage/templates/HTTPNotFound.html decoupage/web.py
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/templates/HTTPNotFound.html	Thu Aug 23 22:03:47 2012 -0700
+++ b/decoupage/templates/HTTPNotFound.html	Thu Aug 23 23:19:07 2012 -0700
@@ -4,11 +4,13 @@
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:py="http://genshi.edgewall.org/"
       xmlns:xi="http://www.w3.org/2001/XInclude">
-  <!-- basic index of files -->
   <head>
     <xi:include href="head.html"/>
   </head>
   <body>
     <xi:include py:if="include" href="${include}"/>
+    <div id="HTTPNotFound">
+      <h1>404 Not Found</h1>
+    </div>
   </body>
 </html>
--- a/decoupage/web.py	Thu Aug 23 22:03:47 2012 -0700
+++ b/decoupage/web.py	Thu Aug 23 23:19:07 2012 -0700
@@ -135,7 +135,12 @@
                 return fileserver(environ, start_response)
         else:
             # file does not exist
-            response = exc.HTTPNotFound()
+            conf = self.conf('/')
+            data = dict(request=request,
+                        title="Not Found")
+            template = self.loader.load('HTTPNotFound.html')
+            body = template.generate(**data).render('html', doctype='html')
+            response = Response(content_type='text/html', body=body, status=404)
             return response(environ, start_response)