app/soc/logic/out_of_band.py
changeset 303 4f1bb54ddae5
parent 293 1edd01373e71
equal deleted inserted replaced
302:3b9c52170f46 303:4f1bb54ddae5
    23 
    23 
    24 
    24 
    25 class OutOfBandResponse(Exception):
    25 class OutOfBandResponse(Exception):
    26   """Base exception for out-of-band responses raised by controller logic.
    26   """Base exception for out-of-band responses raised by controller logic.
    27   """
    27   """
       
    28 
    28   pass
    29   pass
    29 
    30 
    30 
    31 
    31 class ErrorResponse(OutOfBandResponse):
    32 class ErrorResponse(OutOfBandResponse):
    32   """Out-of-band response when controller logic needs a special error page.
    33   """Out-of-band response when controller logic needs a special error page.
    39       message: error message to display on the error page
    40       message: error message to display on the error page
    40       **response_args: keyword arguments that are supplied directly to
    41       **response_args: keyword arguments that are supplied directly to
    41         django.http.HttpResponse; the most commonly used is 'status' to
    42         django.http.HttpResponse; the most commonly used is 'status' to
    42         set the HTTP status code for the response
    43         set the HTTP status code for the response
    43     """
    44     """
       
    45 
    44     self.message = message
    46     self.message = message
    45     self.response_args = response_args
    47     self.response_args = response_args
    46 
       
    47 
       
    48 class AccessViolationResponse(OutOfBandResponse):
       
    49   """"Out of band response when an access requirement was not met.
       
    50   """
       
    51 
       
    52   def __init__(self, response):
       
    53     """Constructor used to set response message \.
       
    54 
       
    55     Args:
       
    56       response: The response that should be returned to the user.
       
    57     """
       
    58 
       
    59     self._response = response
       
    60 
       
    61   def response(self):
       
    62     """Returns the response that was set in the constructor.
       
    63     """
       
    64 
       
    65     return self._response