def validate_entry(self, keys): """ keys-> Entry.__dict__= {'multiple_choices': [(3, 'HER-2/neu')], 'input_choices': [(3, 'sdfsdf')], 'check_box_lines': [0, 3]} """ Entry = ValidatedEntry() if keys.has_key(self.MultipleSelect.get_name): multiple_choices = make_list(keys[self.MultipleSelect.get_name]) else: multiple_choices = [] if keys.has_key(self.MultipleSelect.line_index_name): multiple_choices_lines = make_list(keys[self.MultipleSelect.line_index_name]) else: multiple_choices_lines = [] Entry.multiple_choices = zip(make_ints(multiple_choices_lines), multiple_choices) if keys.has_key(self.Input.get_name): text_inputs = make_list(keys[self.Input.get_name]) else: text_inputs = [] if keys.has_key(self.Input.line_index_name): input_choices_lines = make_list(keys[self.Input.line_index_name]) else: input_choices_lines = [] Entry.input_choices = zip(make_ints(input_choices_lines), text_inputs) if keys.has_key("check_box_line"): Entry.check_box_lines = make_ints(make_list(keys["check_box_line"])) return Entry
def post(self): check_box_lines = make_ints(self.request.get("check_box_line", allow_multiple=True)) multiple_choices = self.request.get("get_multiple_choices", allow_multiple=True) line_choices = make_ints(self.request.get("line_index_selection", allow_multiple=True)) input_entries = self.request.get("get_input_entry", allow_multiple=True) line_index_input = make_ints(self.request.get("line_index_imput", allow_multiple=True)) form_title = self.request.get("new_form_name") # print check_box_lines, "CHECKBOXLINES" # print multiple_choices, "MULTIPLE CHOICES" # print line_choices, "LINE CHOICES" # print input_entries, "INPUT ENTRIES" # print line_index_input, "LINE INDEX INPUT" # print "CHECKBOXLINES" Entry = ValidatedEntry() Entry.multiple_choices = zip(line_choices, multiple_choices) Entry.input_choices = zip(line_index_input, input_entries) Entry.check_box_lines = check_box_lines # print Entry.__dict__, "YEAH...." # print self.request # print self.request.POST.items() # print "BEING CALLED" """keys contains the chosen lines numbers+ a list with all the selected multiple choises""" # for debugging # yield strope(keys) choices = [] t = get_form_key(yaml.load(get_form_content(form_title))) # t=yaml.load(file(cherrypy.session["fileName"]).read()) #['TEST', ['PCR FOR IMMUNOGLOBULIN AND T CELL RECEPTOR GENE REARRANGEMENTS WAS PERFORMED ON', 'PCR FOR IMMUNOGLO [choices.extend(i) for i in (t[i + 1] for i in range(0, len(t), 2))] # ['HER-2/neu gene', .... # yield strope(choices) # print choices, "CHOICES" user = users.get_current_user() q = db.GqlQuery("SELECT * FROM Settings WHERE user = :1", user) if q.get(): user_setting = q.get() header = user_setting.header line_start = user_setting.line_start else: header = "" line_start = "" text = header + "<br>" index = 0 for chosen_check_box_line_index in Entry.check_box_lines: line = choices[chosen_check_box_line_index] + " " # print "RAW", line for multiple_choice in Entry.multiple_choices: # (14, 'decreased') # yield strope(multiple_choice)+strope(chosen_check_box_line_index) if multiple_choice[0] == chosen_check_box_line_index and multiple_choice[1] != "default": # continue # yield "CHOICES MATCH" match = self.MultipleSelect.parse(line) if match: match = match[0] # yield strope(match) line = line.replace(match, multiple_choice[1], 1) if multiple_choice[0] == chosen_check_box_line_index and multiple_choice[1] == "default": # continue # yield "CHOICES MATCH" # yield strope(line) ##print line match = self.MultipleSelect.parse(line) ##print match # yield strope(match) if match: match = match[0] # yield strope(match) line = line.replace(match, "", 1) # print "NOT RAW", line for input_choice in Entry.input_choices: # print input_choice if input_choice[0] == chosen_check_box_line_index: # yield "INPUT MATCH" match = self.Input.parse(line)[0] # print match, "MATCH", type(match) # print line, type(line), match, type(match), input_choice[1], type(input_choice[1]) # continue # yield strope(match) line = line_start + line.replace(match, input_choice[1], 1) # continue text += line text += "<BR>" # if index==0 or index==1: # #continue # text+="<BR>" index += 1 # rendering engine # print text # print text, "HERE I AM" self.response.out.write(web_publish(template.render(self.template_path, {"form_results": text})))