--- a/app/soc/views/out_of_band.py Tue Dec 02 11:20:08 2008 +0000
+++ b/app/soc/views/out_of_band.py Tue Dec 02 17:14:18 2008 +0000
@@ -25,11 +25,6 @@
from django.utils.translation import ugettext_lazy
-from soc.views import helper
-
-import soc.views.helper.responses
-import soc.views.helper.templates
-
class Error(Exception):
"""Base exception for out-of-band responses raised by logic or views.
@@ -45,46 +40,14 @@
the response() method, produces the message to display on the
response page; this can be a simple string containing *no* named
format specifiers
- context: see response()
+ context: see soc.views.helper.responses.errorResponse()
**response_args: keyword arguments that are supplied directly to
django.http.HttpResponse; the most commonly used is 'status' to
set the HTTP status code for the response
"""
self.message_fmt = message_fmt
- self._context = context
- self._response_args = response_args
-
- def response(self, request, template=None, context=None):
- """Creates an HTTP response from the OutOfBandResponse exception.
-
- Args:
- request: a Django HTTP request
- template: the "sibling" template (or a search list of such templates)
- from which to construct the actual template name (or names)
- context: optional context dict supplied to the template, which is
- modified (so supply a copy if such modification is not acceptable)
- """
- if not context:
- context = self._context
-
- if not context:
- context = helper.responses.getUniversalContext(request)
-
- if not template:
- template = []
-
- # make a list of possible "sibling" templates, then append a default
- templates = helper.templates.makeSiblingTemplatesList(template,
- self.TEMPLATE_NAME, default_template=self.DEF_TEMPLATE)
-
- context['status'] = self._response_args.get('status')
-
- if not context.get('message'):
- # supplied context did not explicitly override the message
- context['message'] = self.message_fmt % context
-
- return helper.responses.respond(request, templates, context=context,
- response_args=self._response_args)
+ self.context = context
+ self.response_args = response_args
class LoginRequest(Error):
@@ -100,9 +63,8 @@
"""Constructor used to set response message and HTTP response arguments.
Args:
- message_fmt: same as Error.__init__() message_fmt, with the addition
- of a default value of None, in which case self.DEF_LOGIN_MSG_FMT is
- used
+ message_fmt: same as Error.__init__() message_fmt, with the addition of
+ a default value of None, in which case self.DEF_LOGIN_MSG_FMT is used
**response_args: see Error.__init__()
"""
if not message_fmt: