def __call__(self, *args, **kwargs):\r
if self._params_decoration:\r
for dec in self._params_decoration:\r
- args, kwargs = dec(*args, **kwargs)\r
+ try:\r
+ args, kwargs = dec(*args, **kwargs)\r
+ except ReturnImediatelyException, e:\r
+ return e.ret\r
\r
res = self._callable(*args, **kwargs)\r
\r
\r
return res\r
\r
+class ReturnImediatelyException(Exception):\r
+ def __init__(self, ret):\r
+ super(Exception, self).__init__()\r
+ self.ret = ret\r
+\r
def _check_decoratable(origin, install=True):\r
if not isinstance(origin, DecoratableObject):\r
if inspect.ismethod(origin) and not hasattr(origin, '_decoratable_obj'):\r
from django.core.urlresolvers import reverse, NoReverseMatch\r
from forum.forms import *\r
from forum.utils.html import sanitize_html\r
-from forum.modules import decorate\r
+from forum.modules import decorate, ReturnImediatelyException\r
from datetime import datetime, date\r
from forum.actions import EditProfileAction, FavoriteAction, BonusRepAction, SuspendAction\r
from forum.modules import ui\r
def params(request, id, slug=None):\r
user = get_object_or_404(User, id=id)\r
if private and not (user == request.user or request.user.is_superuser):\r
- return HttpResponseUnauthorized(request)\r
+ raise ReturnImediatelyException(HttpResponseUnauthorized(request))\r
\r
if render_to and (not render_to(user)):\r
- return HttpResponseRedirect(user.get_profile_url())\r
+ raise ReturnImediatelyException(HttpResponseRedirect(user.get_profile_url()))\r
\r
return [request, user], {}\r
\r