def notify(self, message = '', data = None, listener = None): if not data: data = {} try: db = get_session() data['notification_type'] = listener if listener else 'unknown' n = Notif( message = toUnicode(message), data = data ) db.add(n) db.commit() ndict = n.to_dict() ndict['type'] = 'notification' ndict['time'] = time.time() self.frontend(type = listener, data = data) return True except: log.error('Failed notify: %s', traceback.format_exc()) db.rollback() finally: db.close()
def notify(self, message="", data={}, listener=None): db = get_session() data["notification_type"] = listener if listener else "unknown" n = Notif(message=toUnicode(message), data=data) db.add(n) db.commit() ndict = n.to_dict() ndict["type"] = "notification" ndict["time"] = time.time() self.messages.append(ndict) db.close() return True
def notify(self, message = '', data = {}): db = get_session() n = Notif( message = toUnicode(message), data = data ) db.add(n) db.commit() ndict = n.to_dict() ndict['type'] = 'notification' ndict['time'] = time.time() self.messages.append(ndict) db.remove()
def notify(self, message='', data={}, listener=None): db = get_session() data['notification_type'] = listener if listener else 'unknown' n = Notif(message=toUnicode(message), data=data) db.add(n) db.commit() ndict = n.to_dict() ndict['type'] = 'notification' ndict['time'] = time.time() self.frontend(type=listener, data=data) return True
def notify(self, message = '', data = {}, listener = None): db = get_session() data['notification_type'] = listener if listener else 'unknown' n = Notif( message = toUnicode(message), data = data ) db.add(n) db.commit() ndict = n.to_dict() ndict['type'] = 'notification' ndict['time'] = time.time() self.messages.append(ndict) #db.close() return True
def notify(self, message = '', data = None, listener = None): if not data: data = {} db = get_session() data['notification_type'] = listener if listener else 'unknown' n = Notif( message = toUnicode(message), data = data ) db.add(n) db.commit() ndict = n.to_dict() ndict['type'] = 'notification' ndict['time'] = time.time() self.frontend(type = listener, data = data) return True
def notify(self, message='', data=None, listener=None): if not data: data = {} try: db = get_session() data['notification_type'] = listener if listener else 'unknown' n = Notif(message=toUnicode(message), data=data) db.add(n) db.commit() ndict = n.to_dict() ndict['type'] = 'notification' ndict['time'] = time.time() self.frontend(type=listener, data=data) return True except: log.error('Failed notify: %s', traceback.format_exc()) db.rollback() finally: db.close()