Skip to content

Commit

Permalink
Change handling of json response due to underlying library change (#146)
Browse files Browse the repository at this point in the history
* Change handling of json response due to underlying library change
  • Loading branch information
delsim authored and GibbsConsulting committed Apr 21, 2019
1 parent 701df95 commit 70a10c3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions django_plotly_dash/dash_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,14 @@ def dispatch_with_args(self, body, argMap):
state = body.get('state', [])
output = body['output']

target_id = '{}.{}'.format(output['id'], output['property'])
try:
output_id = output['id']
output_property = output['property']
target_id = "%s.%s" %(output_id, output_property)
except:
target_id = output
output_id, output_property = output.split(".")

args = []

da = argMap.get('dash_app', None)
Expand Down Expand Up @@ -491,10 +498,10 @@ def dispatch_with_args(self, body, argMap):
return 'EDGECASEEXIT'

res = self.callback_map[target_id]['callback'](*args, **argMap)
if da and da.have_current_state_entry(output['id'], output['property']):
if da and da.have_current_state_entry(output_id, output_property):
response = json.loads(res.data.decode('utf-8'))
value = response.get('response', {}).get('props', {}).get(output['property'], None)
da.update_current_state(output['id'], output['property'], value)
value = response.get('response', {}).get('props', {}).get(output_property, None)
da.update_current_state(output_id, output_property, value)

return res

Expand Down

0 comments on commit 70a10c3

Please sign in to comment.