Fixing fake response kludge for VOEvent text

Ensuring that VOEvent file text (in fake response kludge) is unicode.
parent ba23f254
......@@ -122,6 +122,14 @@ class ProxyHTTPSConnection(ProxyHTTPConnection):
else:
self.sock = self.context.wrap_socket(self.sock)
# Hacky fake response type for kludging response object
# Has json() and read() methods
class FakeResponse(object):
def __init__(self, json, *args, **kwargs): self._data = json
def json(self): return self._data
def read(self): return json.dumps(self._data)
#-----------------------------------------------------------------
# Generic GSI REST
......@@ -1595,16 +1603,12 @@ class GraceDb(GsiRest):
if 'voevents' in r_json:
# list of voevents - iterate and get file text
for v in r_json['voevents']:
v[u'text'] = self.files(object_id, v['filename']).read()
v[u'text'] = self.files(object_id, v['filename']) \
.read().decode()
else:
file_text = self.files(object_id, r_json['filename']).read()
r_json[u'text'] = file_text
r_json[u'text'] = file_text.decode()
# Set up fake response object with json() and read() methods
class FakeResponse(object):
def __init__(self, json, *args, **kwargs): self._data = json
def json(self): return self._data
def read(self): return json.dumps(self._data)
response = FakeResponse(r_json)
# Return response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment