summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2013-10-07 22:23:21 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2013-10-07 22:23:21 +0000
commit5963a2d3d6860fe57afc138f095bf2d2eb5a7b80 (patch)
tree018d3d8c637e265b8292d34e5f7c11ca8ce11b7d /sca-java-2.x/tags/2.0.1-RC1/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py
parent132aa8a77685ec92bc90c03f987650d275a7b639 (diff)
Official Tuscany 2.0.1 Release
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1530096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py40
1 files changed, 0 insertions, 40 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py
deleted file mode 100644
index d02ae2033a..0000000000
--- a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-python-runtime/src/main/resources/django/utils/simplejson/jsonfilter.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from django.utils import simplejson
-import cgi
-
-class JSONFilter(object):
- def __init__(self, app, mime_type='text/x-json'):
- self.app = app
- self.mime_type = mime_type
-
- def __call__(self, environ, start_response):
- # Read JSON POST input to jsonfilter.json if matching mime type
- response = {'status': '200 OK', 'headers': []}
- def json_start_response(status, headers):
- response['status'] = status
- response['headers'].extend(headers)
- environ['jsonfilter.mime_type'] = self.mime_type
- if environ.get('REQUEST_METHOD', '') == 'POST':
- if environ.get('CONTENT_TYPE', '') == self.mime_type:
- args = [_ for _ in [environ.get('CONTENT_LENGTH')] if _]
- data = environ['wsgi.input'].read(*map(int, args))
- environ['jsonfilter.json'] = simplejson.loads(data)
- res = simplejson.dumps(self.app(environ, json_start_response))
- jsonp = cgi.parse_qs(environ.get('QUERY_STRING', '')).get('jsonp')
- if jsonp:
- content_type = 'text/javascript'
- res = ''.join(jsonp + ['(', res, ')'])
- elif 'Opera' in environ.get('HTTP_USER_AGENT', ''):
- # Opera has bunk XMLHttpRequest support for most mime types
- content_type = 'text/plain'
- else:
- content_type = self.mime_type
- headers = [
- ('Content-type', content_type),
- ('Content-length', len(res)),
- ]
- headers.extend(response['headers'])
- start_response(response['status'], headers)
- return [res]
-
-def factory(app, global_conf, **kw):
- return JSONFilter(app, **kw)