def post(self): applog("INFO: Add_Video_Handler Called") resp_obj = Map() resp_obj.handler = "Add_Video_Handler" in_obj = Map() in_obj.video_name = self.get_argument('video_name', "") in_obj.video_url = self.get_argument('video_url', "") in_obj.video_tags = self.get_argument('video_tags', "") # If the JSON->Python object conversion was sucessfull the server # can access the objects data and return something to the client if 'video_name' in in_obj and 'video_url' in in_obj and 'video_tags' in in_obj: relaxdb = RelaxDB() relaxdb.open() user_id = self.get_current_user() video_id = relaxdb.add_video(in_obj.video_name, in_obj.video_url) relaxdb.map_video(user_id,video_id,in_obj.video_tags) resp_obj.video_list = relaxdb.get_mapped_videos(user_id) resp_obj.call_result = "SUCCESS" relaxdb.close() else: resp_obj.call_result = "FAILURE - Missing fields ", str(in_obj) self.write(json.dumps(resp_obj)) self.finish()
def post(self): applog("INFO: Sign In Called") resp_obj = Map() resp_obj.handler = "Sign_In_Handler" in_obj = Map() in_obj.user_email = self.get_argument('user_email', "") in_obj.user_password = self.get_argument('user_password', "") applog("SECURITY: Attempt to login by user_email %s\n" % in_obj.user_email) # Check Permissions relaxdb = RelaxDB() relaxdb.open() if relaxdb.check_user(in_obj.user_email, in_obj.user_password): user_id = relaxdb.check_user(in_obj.user_email,in_obj.user_password) applog("SECURITY: user_id " + str(user_id) + " has signed in sucessfully") self.set_current_user_id(user_id) resp_obj.call_result = "SUCCESS" resp_obj.user_id = user_id resp_obj.user_name = relaxdb.get_user_name(user_id) resp_obj.video_list = relaxdb.get_mapped_videos(user_id) else: applog("SECURITY: Invalid email or password") resp_obj.call_result = "FAILURE - Invalid email or password" relaxdb.close() self.write(json.dumps(resp_obj)) self.finish()