def edit_location(self, obj): tree = self.view.widget_tree.get_widget('location_treeview') model, iter = tree.get_selection().get_selected() if iter == None: return page = model.get_value(iter, 1) id = model.get_value(iter, 2) document = self.model.get_document_by_page(page) profile = document.get_location_by_id(id) result = self.view.character_dialog(profile) if result == gtk.RESPONSE_OK: self.model.notify()
def get(self, url=''): if url == 'clearpic': pics = Image.all() for pic in pics: pic.delete() self.response.out.write('clear %s' % len(pics)) return if not url.endswith('.jpg'): self.set_status(404) return pic = url[:-4] page = get_img(pic) if page is None: item = get_value('pichost', 'http://pic.caatashoes.com') gourl = '%s/pic/%s' % (item, url) page = self.fetchurl(gourl) if page.status_code != 200: self.set_status(page.status_code) self.setHeader(page) self.response.out.write(page.content) return else: page = page.content put_img(pic, page) self.set_status(200) self.response.headers['content-type'] = 'image/jpeg' self.response.headers['cache-control'] = str(CACHETIME) a = datetime.today() a += timedelta(seconds=31104000) self.response.headers['expires'] = a.strftime('%a, %d %b %Y %X GMT') self.response.headers['accept-ranges'] = 'bytes' self.response.out.write(page)
def choose_question (objects_values, asked_questions): bestCanidates = get_nearby_objects(objects_values, 2) object1 = bestCanidates[0].id object2 = bestCanidates[1].id questions = model.get_questions() biggest_difference = [0, 0] #[Question id, difference] for question in questions: if not(question.id in asked_questions): objectOneAnswer = model.get_value(object1, question.id) objectTwoAnswer = model.get_value(object2, question.id) difference = abs(objectOneAnswer-objectTwoAnswer) if difference > biggest_difference[1]: biggest_difference = [question.id, difference] return model.get_question_by_id(biggest_difference[0])
def delete_patient(self, button): selection = builder.get_object("tree-list").get_selection() selection.set_mode(Gtk.SelectionMode.BROWSE) (model, paths) = selection.get_selected_rows() if len(paths) == 1: for path in paths: tree_iter = model.get_iter(path) self.rowselected = model.get_value(tree_iter, 0) confirm_delete = builder.get_object("confirm_delete_window") confirm_delete.set_title("Confirmar eliminación") confirm_delete.show()
def learn(asked_questions, object_id): '''Updates the data for the correct object based on information in asked_questions. Also updates times played for the object and stores the playlog.''' for question in asked_questions: current_weight = model.get_value(object_id, question) if not(current_weight): current_weight = 0 new_weight = current_weight + asked_questions[question] model.update_data(object_id, question, new_weight) model.update_times_played(object_id) model.record_playlog(object_id, asked_questions, True)
def cachePic(self, url): referer = self.request.referer if referer: for s in block_referer: if referer.find(s) !=-1: self.set_status(404) return if not url.startswith('pic') or not url.endswith('.jpg'): self.set_status(404) return pic = url[4:-4] app = get_value(pic, getApp()) self.set_status(301) self.response.headers['Location'] = str('http://%s.appspot.com/picture/%s.jpg' % (app, pic))
def cachePic(self, url): referer = self.request.referer if referer: for s in block_referer: if referer.find(s) != -1: self.set_status(404) return if not url.startswith('pic') or not url.endswith('.jpg'): self.set_status(404) return pic = url[4:-4] app = get_value(pic, getApp()) self.set_status(301) self.response.headers['Location'] = str( 'http://%s.appspot.com/picture/%s.jpg' % (app, pic))
def get_id(self,model,pathlist): for path in pathlist : tree_iter = model.get_iter(path) value = model.get_value(tree_iter,2) self.b=self.model.search(value) return self.b