2 # This file is part of my.gpodder.org.
4 # my.gpodder.org is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version.
9 # my.gpodder.org is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
12 # License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
18 from django
.http
import HttpResponse
20 from mygpo
.core
.json
import json
23 class JsonResponse(HttpResponse
):
24 def __init__(self
, object, jsonp_padding
=None):
25 content
= json
.dumps(object, ensure_ascii
=True)
28 content
= '%(func)s(%(obj)s)' % \
29 {'func': jsonp_padding
, 'obj': content
}
30 content_type
= 'application/json-p'
33 content_type
= 'application/json'
35 super(JsonResponse
, self
).__init
__(
36 content
, content_type
=content_type
)