app/soc/middleware/maintenance.py
changeset 2906 6fb53ed7aff4
parent 2905 378833eb5a95
equal deleted inserted replaced
2905:378833eb5a95 2906:6fb53ed7aff4
    62     template = 'soc/base.html'
    62     template = 'soc/base.html'
    63 
    63 
    64     return responses.respond(request, template, context=context)
    64     return responses.respond(request, template, context=context)
    65 
    65 
    66   def process_request(self, request):
    66   def process_request(self, request):
       
    67     """Called when a request is made.
       
    68 
       
    69     See the Django middleware documentation for an explanation of
       
    70     the method signature.
       
    71     """
       
    72 
    67     context = responses.getUniversalContext(request)
    73     context = responses.getUniversalContext(request)
    68 
    74 
    69     if not context['is_admin'] and context['in_maintenance']:
    75     if not context['is_admin'] and context['in_maintenance']:
    70       return self.maintenance(request)
    76       return self.maintenance(request)
    71 
    77 
    72   def process_exception(self, request, exception):
    78   def process_exception(self, request, exception):
       
    79     """Called when an uncaught exception is raised.
       
    80 
       
    81     See the Django middleware documentation for an explanation of
       
    82     the method signature.
       
    83     """
       
    84 
    73     if isinstance(exception, CapabilityDisabledError):
    85     if isinstance(exception, CapabilityDisabledError):
    74       # assume the site is in maintenance if we get CDE
    86       # assume the site is in maintenance if we get CDE
    75       return maintenance(request)
    87       return maintenance(request)
    76 
    88 
    77     # let the exception handling middleware handle it
    89     # let the exception handling middleware handle it