Пример #1
0
def tell(tserver, match, fact):
    name = match['Person2']
    if name in tserver.wss:
        template = get_template('templates/tell.html')
        subview = apply_fact(tserver, match['Exist1']['orig'])  ## XXX Security alert. the teller is not necessarily cleared for match['Exists1']['orig']
        toweb = {'fact': fact, 'html': subview['html']}
        try:
            with tserver.wss[name][0]:
                tserver.wss[name][1].send(json.dumps(toweb).encode('utf8'))
        except WebSocketError:
            pass
    return 'OK'
Пример #2
0
 def run(self):
     kb = Client((self.config('kb_host'),
                  int(self.config('kb_port'))))
     fact = self.fact
     localdata.data = self.data
     localdata.user = self.user
     if self.user == 'admin':
         fact += '.'
     else:
         fact = '(want %s, do %s).' % (self.user, fact)
     kb.send_bytes(fact)
     kb.send_bytes('FINISH-TERMS')
     for fact in iter(kb.recv_bytes, 'END'):
         toweb = apply_fact(self.tserver, fact)
         toweb = json.dumps(toweb).encode('utf8')
         try:
             with self.wslock:
                 self.wsock.send(toweb)
         except WebSocketError:
             break
     kb.close()