examples/data_binding/main.py
def on_message(self, message):
        """ When enaml.js sends a message """
        #: Decode message
        change = tornado.escape.json_decode(message)
        #print change
        #: Get the owner ID
        ref = change.get('ref')
        if not ref:
            return
        
        #: Get the server side representation of the node
        #: If found will return the View declaration node
        node = self.view.xpath('//*[@ref="{}"]'.format(ref), first=True)
        if node is None:
            return
        
        #: Handle the event
        if change.get('type') and change.get('name'):
            if change['type'] == 'event':
                #: Trigger the event
                trigger = getattr(node, change['name'])
                trigger()
            if change['type'] == 'update':
                #: Trigger the update
                setattr(node, change['name'], change['value'])
def on_message(self, message):
        """ When enaml.js sends a message """
        #: Decode message
        change = tornado.escape.json_decode(message)
        #print change
        #: Get the owner ID
        ref = change.get('ref')
        if not ref:
            return
        
        #: Get the server side representation of the node
        #: If found will return the View declaration node
        node = self.view.xpath('//*[@ref="{}"]'.format(ref), first=True)
        if node is None:
            return
        
        #: Handle the event
        if change.get('type') and change.get('name'):
            if change['type'] == 'event':
                #: Trigger the event
                trigger = getattr(node, change['name'])
                trigger()
            if change['type'] == 'update':
                #: Trigger the update
                setattr(node, change['name'], change['value'])
When enaml.js sends a message