diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-08-15 10:34:20 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-08-15 10:34:20 -0500 |
commit | 4834ef8ec21e985290f5e0015ae9452070956170 (patch) | |
tree | 365b6043f4a18a40a01d5aa13700ab98ee031613 /mediagoblin/plugins/api | |
parent | 29cd702e4776811a96c3c088bd9ba8fc6f9176f0 (diff) | |
parent | 89909bd6921efb4ec3296c908c5d57eba35ebd21 (diff) | |
download | mediagoblin-4834ef8ec21e985290f5e0015ae9452070956170.tar.lz mediagoblin-4834ef8ec21e985290f5e0015ae9452070956170.tar.xz mediagoblin-4834ef8ec21e985290f5e0015ae9452070956170.zip |
Merge remote-tracking branch 'refs/remotes/tsyesika/master'
New oauth tools! Heck yeah!
Diffstat (limited to 'mediagoblin/plugins/api')
-rw-r--r-- | mediagoblin/plugins/api/tools.py | 24 | ||||
-rw-r--r-- | mediagoblin/plugins/api/views.py | 4 |
2 files changed, 2 insertions, 26 deletions
diff --git a/mediagoblin/plugins/api/tools.py b/mediagoblin/plugins/api/tools.py index 92411f4b..d1b3ebb1 100644 --- a/mediagoblin/plugins/api/tools.py +++ b/mediagoblin/plugins/api/tools.py @@ -51,30 +51,6 @@ class Auth(object): def __call__(self, request, *args, **kw): raise NotImplemented() - -def json_response(serializable, _disable_cors=False, *args, **kw): - ''' - Serializes a json objects and returns a werkzeug Response object with the - serialized value as the response body and Content-Type: application/json. - - :param serializable: A json-serializable object - - Any extra arguments and keyword arguments are passed to the - Response.__init__ method. - ''' - response = Response(json.dumps(serializable), *args, content_type='application/json', **kw) - - if not _disable_cors: - cors_headers = { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With'} - for key, value in cors_headers.iteritems(): - response.headers.set(key, value) - - return response - - def get_entry_serializable(entry, urlgen): ''' Returns a serializable dict() of a MediaEntry instance. diff --git a/mediagoblin/plugins/api/views.py b/mediagoblin/plugins/api/views.py index 9159fe65..b7e74799 100644 --- a/mediagoblin/plugins/api/views.py +++ b/mediagoblin/plugins/api/views.py @@ -21,11 +21,11 @@ from os.path import splitext from werkzeug.exceptions import BadRequest, Forbidden from werkzeug.wrappers import Response +from mediagoblin.tools.response import json_response from mediagoblin.decorators import require_active_login from mediagoblin.meddleware.csrf import csrf_exempt from mediagoblin.media_types import sniff_media -from mediagoblin.plugins.api.tools import api_auth, get_entry_serializable, \ - json_response +from mediagoblin.plugins.api.tools import api_auth, get_entry_serializable from mediagoblin.submit.lib import check_file_field, prepare_queue_task, \ run_process_media, new_upload_entry |