From 3cd96a4f598c679b6443c35dd9fbdfbe2313107a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sun, 20 Mar 2016 13:53:06 -0400 Subject: [PATCH] Force asyncresponse http to be JSON array Rather than let it be ambiguous, force it to provide a JSON array. --- confluent_server/confluent/httpapi.py | 2 +- confluent_server/confluent/messages.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/httpapi.py b/confluent_server/confluent/httpapi.py index 7a1159d9..7a9f0c32 100644 --- a/confluent_server/confluent/httpapi.py +++ b/confluent_server/confluent/httpapi.py @@ -634,7 +634,7 @@ def _assemble_json(responses, resource=None, url=None, extension=None): else: rspdata[dk] = [rspdata[dk], rsp[dk]] else: - if dk == 'databynode': + if dk == 'databynode' or dk == 'asyncresponse': # a quirk, databynode suggests noderange # multi response. This should *always* be a list, # even if it will be length 1 diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index cb824755..8c13c9ac 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -489,8 +489,8 @@ class InputCredential(ConfluentMessage): if node not in self.credentials: return {} credential = self.credentials[node] - for attr in credentials: - if type(credentials[attr]) in (str, unicode): + for attr in credential: + if type(credential[attr]) in (str, unicode): try: # as above, use format() to see if string follows # expression, store value back in case of escapes @@ -843,6 +843,7 @@ class AsyncCompletion(ConfluentMessage): def raw(self): return {'_requestdone': True} + class AsyncMessage(ConfluentMessage): def __init__(self, pair): self.stripped = True @@ -851,8 +852,8 @@ class AsyncMessage(ConfluentMessage): def raw(self): return {'asyncresponse': - {'requestid': self.msgpair[0], - 'response': self.msgpair[1].raw()}} + {'requestid': self.msgpair[0], + 'response': self.msgpair[1].raw()}} class AsyncSession(ConfluentMessage): def __init__(self, id):