def get(self): val = self.initController("MessageController.get()", ["version"]) if not val: return self.response self.response.headers['Content-Type'] = 'application/json' (cont, serverMessage) = getAndroidServerMessage(self.data) if not cont: self.response.out.write( json.dumps({ 'servermessage': serverMessage, "messages": [] })) return self.response if "timestamp" in self.data: timestamp = self.data["timestamp"] else: timestamp = 0 messages = dao.get_messages(self.irssi_user, timestamp) message_jsons = [message.to_json() for message in messages] response_json = json.dumps({ "servermessage": serverMessage, "messages": message_jsons }) self.response.out.write(response_json)
def get(self): val = self.initController("MessageController.get()", ["version"]) if not val: return self.response self.response.headers['Content-Type'] = 'application/json' (cont, serverMessage) = getAndroidServerMessage(self.data) if not cont: self.response.out.write(json.dumps({'servermessage': serverMessage, "messages": []})) return self.response if "timestamp" in self.data: timestamp = self.data["timestamp"] else: timestamp = 0 messages = dao.get_messages(self.irssi_user, timestamp) message_jsons = [message.to_json() for message in messages] response_json = json.dumps({"servermessage": serverMessage, "messages": message_jsons}) self.response.out.write(response_json)