diff --git a/r2/r2/controllers/validator/validator.py b/r2/r2/controllers/validator/validator.py index 2139ed19a..0543bf48b 100644 --- a/r2/r2/controllers/validator/validator.py +++ b/r2/r2/controllers/validator/validator.py @@ -296,7 +296,10 @@ class VUser(Validator): if not c.user_is_loggedin: #TODO return a real error page d = dict(dest=reddit_link(request.path, url = True) + utils.query_string(request.GET)) - return redirect_to("/login" + utils.query_string(d)) + path = "/login" + if request.environ.get('extension'): + path += ".%s" % request.environ['extension'] + return redirect_to(path + utils.query_string(d)) if (password is not None) and not valid_password(c.user, password): c.errors.add(errors.WRONG_PASSWORD) diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 52f48e3ee..60d0b2279 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -19,19 +19,21 @@ # All portions of the code written by CondeNet are Copyright (c) 2006-2008 # CondeNet, Inc. All Rights Reserved. ################################################################################ -from r2.lib.wrapped import Wrapped +from r2.lib.wrapped import Wrapped, NoTemplateFound from r2.models import IDBuilder, LinkListing, Account, Default, FakeSubreddit, Subreddit from r2.config import cache from r2.lib.jsonresponse import json_respond from r2.lib.jsontemplates import is_api from pylons.i18n import _ from pylons import c, request, g +from pylons.controllers.util import abort, redirect_to from r2.lib.captcha import get_iden from r2.lib.filters import spaceCompress, _force_unicode from r2.lib.menus import NavButton, NamedButton, NavMenu, PageNameNav, JsButton, menu from r2.lib.strings import plurals, rand_strings, strings from r2.lib.utils import title_to_url +import sys def get_captcha(): if not c.user_is_loggedin or c.user.needs_captcha(): @@ -135,12 +137,21 @@ class Reddit(Wrapped): In adition, unlike Wrapped.render, the result is in the form of a pylons Response object with it's content set. """ - res = Wrapped.render(self, *a, **kw) - if is_api(): - res = json_respond(res) - elif self.space_compress: - res = spaceCompress(res) - c.response.content = res + try: + res = Wrapped.render(self, *a, **kw) + if is_api(): + res = json_respond(res) + elif self.space_compress: + res = spaceCompress(res) + c.response.content = res + except NoTemplateFound, e: + # re-raise the error -- development environment + if g.debug: + s = sys.exc_info() + raise s[1], None, s[2] + # die gracefully -- production environment + else: + abort(404, "not found") return c.response def corner_buttons(self): diff --git a/r2/r2/lib/wrapped.py b/r2/r2/lib/wrapped.py index cbbe988dd..1c2a51e9a 100644 --- a/r2/r2/lib/wrapped.py +++ b/r2/r2/lib/wrapped.py @@ -47,7 +47,7 @@ class Wrapped(object): pass if not found: - raise AttributeError, attr + raise NoTemplateFound, attr setattr(self, attr, res) return res @@ -71,8 +71,8 @@ class Wrapped(object): else: try: template = tpm.get(self, style, cache = not debug) - except KeyError: - raise NoTemplateFound, repr(self) + except AttributeError: + raise NoTemplateFound, (repr(self), style) return template diff --git a/r2/r2/templates/unfoundpage.html b/r2/r2/templates/unfoundpage.html index 3b2c27093..581881eaf 100644 --- a/r2/r2/templates/unfoundpage.html +++ b/r2/r2/templates/unfoundpage.html @@ -17,7 +17,7 @@ ## the Original Code is CondeNet, Inc. ## ## All portions of the code written by CondeNet are Copyright (c) 2006-2008 -## CondeNet, Inc. All Rights Reserved. +## CondeNet, Inc. All Rights Reserved." ################################################################################
+${_("the page you requested does not exist")}
+