diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-08-20 15:55:08 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-08-20 15:55:08 -0500 |
commit | bae8f3d8c20b5724abf5ac99776ae582d0a94689 (patch) | |
tree | bae0275c93bdd684d79547df380f8cff90658812 /mediagoblin/util.py | |
parent | a7c641d11ed9d161648dbd4472991d5a5d06afd3 (diff) | |
download | mediagoblin-bae8f3d8c20b5724abf5ac99776ae582d0a94689.tar.lz mediagoblin-bae8f3d8c20b5724abf5ac99776ae582d0a94689.tar.xz mediagoblin-bae8f3d8c20b5724abf5ac99776ae582d0a94689.zip |
Adding and making use of the new 404 error page :)
Diffstat (limited to 'mediagoblin/util.py')
-rw-r--r-- | mediagoblin/util.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/mediagoblin/util.py b/mediagoblin/util.py index b588fa72..0b6428da 100644 --- a/mediagoblin/util.py +++ b/mediagoblin/util.py @@ -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) |