Revision 7ac2131c snf-astakos-app/astakos/api/util.py
b/snf-astakos-app/astakos/api/util.py | ||
---|---|---|
36 | 36 |
|
37 | 37 |
from django.http import HttpResponse |
38 | 38 |
from django.utils import simplejson as json |
39 |
from django.template.loader import render_to_string |
|
39 | 40 |
|
40 | 41 |
from astakos.im.models import AstakosUser, Service |
41 | 42 |
from snf_django.lib.api import faults |
... | ... | |
60 | 61 |
return response |
61 | 62 |
|
62 | 63 |
|
64 |
def xml_response(content, template, status_code=None): |
|
65 |
response = HttpResponse() |
|
66 |
if status_code is not None: |
|
67 |
response.status_code = status_code |
|
68 |
|
|
69 |
response.content = render_to_string(template, content) |
|
70 |
response['Content-Type'] = 'application/xml; charset=UTF-8' |
|
71 |
response['Content-Length'] = len(response.content) |
|
72 |
return response |
|
73 |
|
|
74 |
|
|
63 | 75 |
def is_integer(x): |
64 | 76 |
return isinstance(x, (int, long)) |
65 | 77 |
|
... | ... | |
174 | 186 |
except: |
175 | 187 |
return HttpResponse(status=502) |
176 | 188 |
return HttpResponse(status=200) |
189 |
|
|
190 |
|
|
191 |
def rename_meta_key(d, old, new): |
|
192 |
if old not in d: |
|
193 |
return |
|
194 |
d[new] = d[old] |
|
195 |
del(d[old]) |
Also available in: Unified diff