Refactor message handling in TwythonStreamer #225

Merged
extesy merged 2 commits from master into master 2013-06-21 07:37:48 -07:00
Showing only changes of commit 50cee5ede8 - Show all commits

View file

@ -114,9 +114,8 @@ class TwythonStreamer(object):
for message_type in self.handlers: for message_type in self.handlers:
if message_type in data: if message_type in data:
handler = getattr(self, 'on_' + message_type, None) handler = getattr(self, 'on_' + message_type, None)
if handler and callable(handler): if handler and callable(handler) and not handler(data.get(message_type)):
if not handler(data.get(message_type)): break
break
except ValueError: except ValueError:
self.on_error(response.status_code, 'Unable to decode response, not valid JSON.') self.on_error(response.status_code, 'Unable to decode response, not valid JSON.')