def handle_message(self, msg): if not msg.service == self.service_id: return False if msg.type == "GET": filename = str(msg.destination_key) content = self.lookup_record(str(filename)) #this add other instances of database messages are borked return_service = msg.get_content("service") newmsg = Database_Message(self.owner, msg.reply_to.key, return_service, "RESP") newmsg.add_content("file_contents",content) self.send_message(newmsg, msg.reply_to) if msg.type == "PUT": filename = str(msg.destination_key) self.write_record(filename, msg.get_content("file_contents")) if msg.type == "RESP": print msg.get_content("file_contents")
def handle_message(self, msg): if not msg.service == self.service_id: return False if msg.type == "GET": filename = str(msg.destination_key) content = self.lookup_record(str(filename)) #this add other instances of database messages are borked return_service = msg.get_content("service") newmsg = Database_Message(self.owner, msg.reply_to.key, return_service, "RESP") newmsg.add_content("file_contents", content) self.send_message(newmsg, msg.reply_to) if msg.type == "PUT": filename = str(msg.destination_key) self.write_record(filename, msg.get_content("file_contents")) if msg.type == "RESP": print msg.get_content("file_contents")
def put_record(self,name,data): hash_loc = hash_util.hash_str(name) newmsg = Database_Message(self.owner,hash_loc,"DATABASE","PUT") newmsg.add_content("file_contents",data) self.send_message(newmsg)
def get_record(self, name): hash_loc = hash_util.hash_str(name) newmsg = Database_Message(self.owner, hash_loc, "ECHO", "GET") self.send_message(newmsg)
def put_record(self, name, data): hash_loc = hash_util.hash_str(name) newmsg = Database_Message(self.owner, hash_loc, "DATABASE", "PUT") newmsg.add_content("file_contents", data) self.send_message(newmsg)