def comparator(self, arg, relational): """Compare query records with queried records.""" val_list = [] if isinstance(arg, type(SORT)): if isinstance(arg.records, type(None)): print("The (r.h.s.) sort object has NULL records..") return self else: if len(arg.records) == 0: print("The (r.h.s.) sort object has ZERO records..") return self else: print("Multi-search in progress...") for i in arg.records: val_list.append(i) else: val_list = arg if isinstance(self, type(list)): print("Both of the relational args cannot be lists") return self if isinstance(self.records, type(None)): # print("The (l.h.s.) sort object has NULL records..") return self else: if len(self.records) == 0: self.records = query.find(relational, val_list, self.original, self.series, self.lookup, self.binseries) else: self.records = query.find(relational, val_list, self.original, self.series, self.lookup, self.binseries, self.records) return self
def do_login(): if request.method == "POST": if query.find((request.form['pass'], request.form['uname'])): session['logged_in'] = True session['name'] = request.form['uname'] name = query.getnameuser("users", request.form['uname']) session['id'] = name[0][1] return redirect(url_for("home")) else: if (request.form['pass'] == "" and request.form['uname'] == ""): return redirect(url_for("home")) else: return "wrong password!" + "<br><br><a href='/'>go to home</a>" if request.method == "GET": if session.get('logged_in') is not None: if session.get('logged_in'): redirect(url_for("home")) return render_template("login.html")
def _reflow_idle_cb(self): self._box.clear() self._entries = [] self._vadjustment.props.page_size = self._page_size self._vadjustment.props.page_increment = self._page_size self._vadjustment_changed() if self._result_set is None: self._result_set = query.find(self._store, self._query) max_value = max(0, self._result_set.length - self._page_size) if self._vadjustment.props.value > max_value: self._vadjustment.props.value = max_value else: self._do_scroll(force=True) self._reflow_sid = 0
def refresh(self): if self._result_set: self._result_set.destroy() self._result_set = query.find(self._store, self._query) self._vadjustment.props.upper = self._result_set.length self._vadjustment.changed() self._vadjustment.props.value = min(self._vadjustment.props.value, self._result_set.length -self._page_size) if self._result_set.length == 0: if self._query.get('query', ''): self._show_message(NO_MATCH) else: self._show_message(NOTHING_TO_SHOW) else: self._clear_message() self._do_scroll(force=True)
def intersect(self, a_sort): """Find intersection of querie records with queried records.""" intersect = [] a_sort_mt = isinstance(self.records, type(None)) self_mt = isinstance(a_sort.records, type(None)) if not a_sort_mt: if len(self.records) == 0: a_sort_mt = 1 if not a_sort_mt: return a_sort.records else: return None if not self_mt: if len(a_sort.records) == 0: self_mt = 1 if not self_mt: return self.records else: return None if ((not a_sort_mt) and (not self_mt)): relational = 'E' sorted_a_sort_recs = SORT(list(a_sort.records)) sorted_self_recs = SORT(list(self.records)) sorted_self_recs.sortbymedian() sorted_a_sort_recs.sortbymedian() sorted_self_recs.records = query.find(relational, sorted_a_sort_recs.series, sorted_self_recs.original, sorted_self_recs.series, sorted_self_recs.lookup, sorted_self_recs.binseries) if not isinstance(sorted_self_recs.records, type(None)): for i in sorted_self_recs.records: intersect.append(sorted_self_recs.lookup[i]) return intersect