Adding and making use of the new 404 error page :)
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 20 Aug 2011 20:55:08 +0000 (15:55 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 20 Aug 2011 20:55:08 +0000 (15:55 -0500)
mediagoblin/app.py
mediagoblin/util.py

index 96a7ad61f5ffa35ae0ec8677a06d136e2cef1e80..1a115a229f332fbb874faa923bc8cc207e55d876 100644 (file)
@@ -133,7 +133,7 @@ class MediaGoblinApp(object):
                 return request.get_response(redirect)(environ, start_response)
 
             # Okay, no matches.  404 time!
-            return exc.HTTPNotFound()(environ, start_response)
+            return util.render_404(request)(environ, start_response)
 
         controller = util.import_component(route_match['controller'])
         request.start_response = start_response
index b588fa7265b287ebfb4ed6291d390c8dd8ef1d66..0b6428daa0f4de8d87dfcbc513a4ccc0bf6a8304 100644 (file)
@@ -348,8 +348,10 @@ def get_locale_from_request(request):
     accept_lang_matches = request.accept_language.best_matches()
 
     # Your routing can explicitly specify a target language
-    if request.matchdict.has_key('locale'):
-        target_lang = request.matchdict['locale']
+    matchdict = request.matchdict or {}
+
+    if matchdict.has_key('locale'):
+        target_lang = matchdict['locale']
     elif request.session.has_key('target_lang'):
         target_lang = request.session['target_lang']
     # Pull the first acceptable language
@@ -662,3 +664,11 @@ def gridify_cursor(this_cursor, num_cols=5):
     the number of columns in the list
     """
     return gridify_list(list(this_cursor), num_cols)
+
+
+def render_404(request):
+    """
+    Render a 404.
+    """
+    return render_to_response(
+        request, 'mediagoblin/404.html', {}, status=400)