app/soc/logic/out_of_band.py
author Sverre Rabbelier <srabbelier@gmail.com>
Wed, 22 Oct 2008 06:19:12 +0000
changeset 403 d3e545a8bd26
parent 303 4f1bb54ddae5
permissions -rw-r--r--
Some more improvements to the generic view code Namely getEmptyKeyFields and constructKeyNameSuffix, some whitespace issues, and a few extra fields in the context. Patch by: Sverre Rabbelier Reviewd by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
111
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""Out-of-band responses to render instead of the usual HTTP response.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
"""
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
__authors__ = [
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
  '"Todd Larsen" <tlarsen@google.com>',
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
  ]
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
class OutOfBandResponse(Exception):
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
  """Base exception for out-of-band responses raised by controller logic.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
  """
303
4f1bb54ddae5 Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents: 293
diff changeset
    28
111
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
  pass
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
class ErrorResponse(OutOfBandResponse):
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
  """Out-of-band response when controller logic needs a special error page.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
  """
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
  def __init__(self, message, **response_args):
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
    """Constructor used to set error message and HTTP response arguments.
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
  
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
    Args:
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
      message: error message to display on the error page
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
      **response_args: keyword arguments that are supplied directly to
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
        django.http.HttpResponse; the most commonly used is 'status' to
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
        set the HTTP status code for the response
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
    """
303
4f1bb54ddae5 Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents: 293
diff changeset
    45
111
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
    self.message = message
f506a22f50db Exception classes used by controller logic to request an "out-of-band" response
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
    self.response_args = response_args