event_queue: Add requests 1.x compatibility.

The previous version of our code only worked with python-requests <
1.0 (as is the case on our servers), the new version will work with
any python-requests new enough to have a .json at all.

(imported from commit 77ffe3e0d890fe88776c313e0e3289aee1bb30ea)
This commit is contained in:
Tim Abbott 2013-03-29 11:08:24 -04:00
parent 9acf6bd901
commit 1123d43b1a

View file

@ -39,7 +39,7 @@ __version__ = "0.1.5"
# Older versions don't provide the 'json' attribute on responses. # Older versions don't provide the 'json' attribute on responses.
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1')) assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1'))
# In newer versions, the 'json' attribute is a function, not a property # In newer versions, the 'json' attribute is a function, not a property
requests_json_is_function = not isinstance(requests.Response.json, property) requests_json_is_function = callable(requests.Response.json)
API_VERSTRING = "/api/v1/" API_VERSTRING = "/api/v1/"