25 |
25 |
26 import logging |
26 import logging |
27 |
27 |
28 from functools import wraps |
28 from functools import wraps |
29 |
29 |
30 from google.appengine.api import users |
|
31 from google.appengine.runtime import DeadlineExceededError |
30 from google.appengine.runtime import DeadlineExceededError |
32 from google.appengine.runtime.apiproxy_errors import CapabilityDisabledError |
31 from google.appengine.runtime.apiproxy_errors import CapabilityDisabledError |
33 |
32 |
34 |
33 |
35 from django import http |
34 from django import http |
59 if (not no_redirect) and timeline.isActivePeriod(site, 'maintenance'): |
58 if (not no_redirect) and timeline.isActivePeriod(site, 'maintenance'): |
60 return http.HttpResponseRedirect('/maintenance') |
59 return http.HttpResponseRedirect('/maintenance') |
61 |
60 |
62 try: |
61 try: |
63 return func(request, *args, **kwds) |
62 return func(request, *args, **kwds) |
64 except DeadlineExceededError, e: |
63 except DeadlineExceededError, exception: |
65 logging.exception(e) |
64 logging.exception(exception) |
66 return http.HttpResponseRedirect('/soc/content/deadline_exceeded.html') |
65 return http.HttpResponseRedirect('/soc/content/deadline_exceeded.html') |
67 except CapabilityDisabledError, e: |
66 except CapabilityDisabledError, exception: |
68 logging.exception(e) |
67 logging.exception(exception) |
69 # assume the site is in maintenance if we get CDE |
68 # assume the site is in maintenance if we get CDE |
70 return http.HttpResponseRedirect('/maintenance') |
69 return http.HttpResponseRedirect('/maintenance') |
71 except MemoryError, e: |
70 except MemoryError, exception: |
72 logging.exception(e) |
71 logging.exception(exception) |
73 return http.HttpResponseRedirect('/soc/content/memory_error.html') |
72 return http.HttpResponseRedirect('/soc/content/memory_error.html') |
74 except AssertionError, e: |
73 except AssertionError, exception: |
75 logging.exception(e) |
74 logging.exception(exception) |
76 return http.HttpResponseRedirect('/soc/content/assertion_error.html') |
75 return http.HttpResponseRedirect('/soc/content/assertion_error.html') |
77 |
76 |
78 return view_wrapper |
77 return view_wrapper |
79 |
78 |
80 |
79 |
99 """ |
98 """ |
100 |
99 |
101 # Do not pollute helper.decorators with access specific imports |
100 # Do not pollute helper.decorators with access specific imports |
102 from soc.views import out_of_band |
101 from soc.views import out_of_band |
103 from soc.views import helper |
102 from soc.views import helper |
104 from soc.views.helper import access |
|
105 from soc.views.helper import responses |
103 from soc.views.helper import responses |
106 |
104 |
107 @wraps(func) |
105 @wraps(func) |
108 def wrapper(self, request, access_type, *args, **kwargs): |
106 def wrapper(self, request, access_type, *args, **kwargs): |
109 params = kwargs.get('params', {}) |
107 params = kwargs.get('params', {}) |