X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/410bfa05ee36ed1d99356c443a5f3f6aa3ee9578..cbbbe9e150dfe0f6b9bb47cb5b3f3ed071aca73a:/forum/views/decorators.py diff --git a/forum/views/decorators.py b/forum/views/decorators.py index 44ec8ba..37413d2 100644 --- a/forum/views/decorators.py +++ b/forum/views/decorators.py @@ -1,6 +1,6 @@ -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.utils import simplejson -from django.core.paginator import Paginator +from django.core.paginator import Paginator, EmptyPage from django.shortcuts import render_to_response from django.template import RequestContext from django.utils.translation import ungettext, ugettext as _ @@ -29,7 +29,11 @@ def list(paginate, default_page_size): big_list = context[paginate] paginator = Paginator(big_list, pagesize) - page_obj = paginator.page(page) + try: + page_obj = paginator.page(page) + except EmptyPage: + raise Http404() + context[paginate] = page_obj.object_list.lazy() base_path = context.get('base_path', None) or request.path @@ -71,13 +75,13 @@ def command(func): response['success'] = True except Exception, e: - import sys, traceback - traceback.print_exc(file=sys.stdout) + #import sys, traceback + #traceback.print_exc(file=sys.stdout) if isinstance(e, CommandException): response = { 'success': False, - 'error_message': str(e) + 'error_message': e.message } else: logging.error("%s: %s" % (func.__name__, str(e)))