Open pierce27 opened 9 years ago
So here is the problem—it's not consistent. For instance:
>>> td
TargetDimension(_type='target_dimension', parent='strategies', incldue=[], parent_id=683880, exclude=[], include=[TargetValue(_type='target_value', code='Laptop/Desktop', name='Laptop/Desktop', is_targetable=True, value=43000, target_dimension_id=24, id=301523)], id=24)
>>> td.include = []
>>> td.save()
>>> td.add(td.include, 301523)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/models/targetdimension.py", line 79, in add
'/'.join(url))
File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/connection.py", line 80, in _get
raise ClientError('Could not parse XML response: {!r}'.format(exc))
terminalone.errors.ClientError: "Could not parse XML response: ParseError('no element found: line 1, column 0',)"
>>> td.add(td.include, 301523)
>>> td.save()
>>> td.include = []
>>> td.save()
>>> td.add(td.include, 301523)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/models/targetdimension.py", line 79, in add
'/'.join(url))
File "/Users/pswaminathan/.virtualenvs/t1pyprod/lib/python2.7/site-packages/terminalone/connection.py", line 80, in _get
raise ClientError('Could not parse XML response: {!r}'.format(exc))
terminalone.errors.ClientError: "Could not parse XML response: ParseError('no element found: line 1, column 0',)"
>>> td.response.request.headers
{'Connection': 'keep-alive', 'Cookie': 'adama_session=e8f8dfee49aaa36c908439d51dff09f4d8547d55', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'User-Agent': 't1-python/1.0.4 python-requests/2.8.0'}
>>> td.response.request.url
'https://api.mediamath.com/api/v2.0/target_values/301523?api_key=removed'
>>> td.response.headers
{'Content-Length': '0', 'Connection': 'keep-alive', 'Server': 'Jetty(8.1.3.v20120522)'}
>>> td.response.status_code
400
>>> td.response.content
''
Here, it breaks on the first include, then works, then breaks again the next time. I've also had it break on save. I've also had it never break on the include.
We're looking into this. But it's not straightforward.
@Cawb07 @rolandcrosby
Note that this also affects @amnoonan
If you run the below code in interpreter:
the last get will output following traceback: