aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pubnub.py2
-rw-r--r--python/examples/history.py12
2 files changed, 13 insertions, 1 deletions
diff --git a/pubnub.py b/pubnub.py
index 3b9a488..fcbf2dc 100644
--- a/pubnub.py
+++ b/pubnub.py
@@ -920,7 +920,7 @@ class PubnubBase(object):
def _get_decrypted_history(resp):
try:
- if resp and resp[1] is not None and self.cipher_key:
+ if resp is not None and isinstance(resp, (list)) and resp[1] is not None and self.cipher_key:
msgs = resp[0]
for i in range(0,len(msgs)):
msgs[i] = self.decrypt(msgs[i])
diff --git a/python/examples/history.py b/python/examples/history.py
index 5b92828..19593e1 100644
--- a/python/examples/history.py
+++ b/python/examples/history.py
@@ -33,3 +33,15 @@ def callback(message):
print(message)
pubnub.history(channel, count=2, callback=callback, error=callback)
+
+# Synchronous usage
+
+print pubnub.history(channel, count=2, include_token=True)
+
+# Asynchronous usage
+
+
+def callback(message):
+ print(message)
+
+pubnub.history(channel, count=2, include_token=True, callback=callback, error=callback)