Getting application settings from SockJS Handler

134 views
Skip to first unread message

Truong Tho Nguyen

unread,
Apr 20, 2013, 3:06:11 PM4/20/13
to soc...@googlegroups.com
I tried following code, however, got error from that:

class SocketHandler(sockjs.tornado.SockJSConnection):
    """Chat connection implementation"""
    def on_message(self, message):
        scope = self.settings['db'].scope


here is the log:

AttributeError: 'SocketHandler' object has no attribute 'settings'

How can I get setting from Application then?

Thanks

Serge S. Koval

unread,
Apr 20, 2013, 3:33:27 PM4/20/13
to nguyentru...@gmail.com, sockjs
SockJSConnection and SockJSRouter do not capture application instance.

If you want to have access to it:
1. Subclass SockJSRouter, pass application instance to the constructor and store it there;
2. In SockJSConnection you can use `self.session.server` to access router instance. 

So, if you stored application as `self.app` in SockJSRouter, then you can access it using `self.session.server.app`

Serge.


--
You received this message because you are subscribed to the Google Groups "sockjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sockjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Truong Tho Nguyen

unread,
Apr 20, 2013, 3:48:17 PM4/20/13
to soc...@googlegroups.com, nguyentru...@gmail.com
That's a clear answer, thanks a lot!
Reply all
Reply to author
Forward
0 new messages