# HG changeset patch # User Sverre Rabbelier # Date 1251485252 25200 # Node ID 03a1602c63f1fb46066feee0a209c8008ae77705 # Parent 5aa891de5aa5d615ffb3b2d97db1f84113eaa8ed Hook up the new per-request value storage diff -r 5aa891de5aa5 -r 03a1602c63f1 app/soc/views/helper/decorators.py --- a/app/soc/views/helper/decorators.py Fri Aug 28 11:45:55 2009 -0700 +++ b/app/soc/views/helper/decorators.py Fri Aug 28 11:47:32 2009 -0700 @@ -34,6 +34,7 @@ from django.utils.translation import ugettext from soc.logic import dicts +from soc.modules import callback from soc.views.helper import responses @@ -86,28 +87,39 @@ """View decorator wrapper method. """ - context = responses.getUniversalContext(request) + core = callback.getCore() + core.startNewRequest(request) + + def view_wrapper_helper(): + """View wrapper helper that does all the work. + """ + + context = responses.getUniversalContext(request) + + try: + if not context['is_admin'] and context['in_maintenance']: + return maintenance(request) - try: - if not context['is_admin'] and context['in_maintenance']: + return func(request, *args, **kwds) + except CapabilityDisabledError, exception: + logging.exception(exception) + # assume the site is in maintenance if we get CDE return maintenance(request) + except DeadlineExceededError, exception: + template = 'soc/deadline_exceeded.html' + except MemoryError, exception: + template = 'soc/memory_error.html' + except AssertionError, exception: + template = 'soc/assertion_error.html' + except out_of_band.Error, error: + return responses.errorResponse(error, request) - return func(request, *args, **kwds) - except CapabilityDisabledError, exception: logging.exception(exception) - # assume the site is in maintenance if we get CDE - return maintenance(request) - except DeadlineExceededError, exception: - template = 'soc/deadline_exceeded.html' - except MemoryError, exception: - template = 'soc/memory_error.html' - except AssertionError, exception: - template = 'soc/assertion_error.html' - except out_of_band.Error, error: - return responses.errorResponse(error, request) + return responses.respond(request, template, context=context) - logging.exception(exception) - return responses.respond(request, template, context=context) + result = view_wrapper_helper() + core.endRequest(request) + return result return view_wrapper