app/soc/views/out_of_band.py
changeset 303 4f1bb54ddae5
child 543 280a1ac6bcc1
equal deleted inserted replaced
302:3b9c52170f46 303:4f1bb54ddae5
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2008 the Melange authors.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #   http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 
       
    17 """Out-of-band responses to render instead of the usual HTTP response.
       
    18 """
       
    19 
       
    20 __authors__ = [
       
    21   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
       
    22   ]
       
    23 
       
    24 
       
    25 class OutOfBandResponse(Exception):
       
    26   """Base exception for out-of-band responses raised by views.
       
    27   """
       
    28 
       
    29   pass
       
    30 
       
    31 
       
    32 class AccessViolationResponse(OutOfBandResponse):
       
    33   """"Out of band response when an access requirement was not met.
       
    34   """
       
    35 
       
    36   def __init__(self, response):
       
    37     """Constructor used to set response message.
       
    38 
       
    39     Args:
       
    40       response: The response that should be returned to the user.
       
    41     """
       
    42 
       
    43     self._response = response
       
    44 
       
    45   def response(self):
       
    46     """Returns the response that was set in the constructor.
       
    47     """
       
    48 
       
    49     return self._response