socketubs/django-bagou — pull request #1 by smvv (2014-06-04 08:10:12+00:00)
Title: Fix cookie parsing and get() on NoneType object

This PR will fix two errors that occurred immediately while using the demo.

The first error occurs while parsing cookies:
~~~
INFO:tornado.handler:Cookie: csrftoken=B8s[...]VRAdr
ERROR:tornado.application:Uncaught exception in /websocket
Traceback (most recent call last):
File "/home/smvv/django-bagou/example/virtenv/local/lib/python2.7/site-packages/tornado/websocket.py", line 303, in wrapper
return callback(*args, **kwargs)
File "/home/smvv/django-bagou/bagou/handler.py", line 133, in on_message
self._on_authenticate(message_json)
File "/home/smvv/django-bagou/bagou/handler.py", line 50, in _on_authenticate
for key, value in cookie.split(';'):
ValueError: too many values to unpack
~~~

The second errors occurs when there is no message given for a triggered event:
~~~
ERROR:tornado.application:Uncaught exception in /websocket
Traceback (most recent call last):
File "/home/smvv/django-bagou/example/virtenv/local/lib/python2.7/site-packages/tornado/websocket.py", line 303, in wrapper
return callback(*args, **kwargs)
File "/home/smvv/django-bagou/bagou/handler.py", line 35, in open
on_open.send(self)
File "/home/smvv/django-bagou/bagou/events.py", line 66, in send
callback = message.get('callbackId')
AttributeError: 'NoneType' object has no attribute 'get'
~~~