summaryrefslogtreecommitdiffstats
path: root/askbot/utils/http.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-11-24 01:32:54 -0500
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-11-24 01:32:54 -0500
commitf416fa800d156141cce7a5f0cdd8576b1a276ab5 (patch)
tree790cbf03e252bd46d61778cee0172549896986be /askbot/utils/http.py
parent2f9594a522a551a35d12aa7697a0a7bf41237020 (diff)
downloadaskbot-f416fa800d156141cce7a5f0cdd8576b1a276ab5.tar.gz
askbot-f416fa800d156141cce7a5f0cdd8576b1a276ab5.tar.bz2
askbot-f416fa800d156141cce7a5f0cdd8576b1a276ab5.zip
comment editing works
Diffstat (limited to 'askbot/utils/http.py')
-rw-r--r--askbot/utils/http.py34
1 files changed, 0 insertions, 34 deletions
diff --git a/askbot/utils/http.py b/askbot/utils/http.py
deleted file mode 100644
index a3aea72d..00000000
--- a/askbot/utils/http.py
+++ /dev/null
@@ -1,34 +0,0 @@
-"""http utils similar to django's but with more
-specific properties
-"""
-import logging
-from django.http import HttpResponse
-from django.utils import simplejson
-
-class JsonResponse(HttpResponse):
- """response class that receives a dictionary
- and returns it serialized with simplejson
- and response type application/json
- """
- def __init__(self, *args, **kwargs):
- mimetype = kwargs.pop('mimetype', None)
- if mimetype:
- raise KeyError('JsonResponse does not accept mimetype variable')
- kwargs['mimetype'] = 'application/json'
- string_data = simplejson.dumps(kwargs.pop('data', ''))
- super(JsonResponse, self).__init__(string_data, *args, **kwargs)
-
-class JsonLoggingErrorResponse(JsonResponse):
- """like json response, only with empty content
- and status=500, plus logs an error message
- """
- def __init__(self, error, *args, **kwargs):
- status = kwargs.pop('status', None)
- if status:
- raise KeyError('JsonLoggingErrorResponse does not accept status')
- log_level = kwargs.pop('log_level', 'debug')
- assert(log_level in ('debug', 'critical'))
- log = getattr(logging, log_level)
- log('ajax error ' + unicode(error))
- kwargs['status'] = 500
- super(JsonLoggingErrorResponse, self).__init__(*args, **kwargs)