def display_r(id): ms = [] r = mreg.get(mreg.c.id == id) b = mbits.filter(mbits.c.reg_id == id) for b1 in b: m = mmeanings.filter(mmeanings.c.bits_id==b1.id) for m1 in m: ms.append(m1) return {'r':r,'b':b,'ms':ms}
def add_mean(bits_name,bits_id): if require_login(): return redirect(url_for(login)) form = MeaningsForm() if request.method == 'GET': m=mmeanings.filter(mmeanings.c.bits_id==bits_id) return {'form':form,'m':m} elif request.method == 'POST': flag = form.validate(request.params) if flag: n = mmeanings(**form.data) m = mmeanings.filter(mmeanings.c.val == form.data.val).filter(mmeanings.c.bits_id==bits_id) for m1 in m: return redirect('/message/该值已经存在/-1') n.bits_name = bits_name n.bits_id = bits_id n.save() return redirect('/regs/add_mean/%s/%s'% (bits_name,bits_id)) else: message='错误' return {'form':form}
def search(id): if request.method == 'GET': return redirect("/regs/display_r/%s"% id) m = [] ms = [] b1 = [] r = mreg.get(mreg.c.id == id) b = mbits.filter(mbits.c.reg_id == id) if request.method == 'POST': rvalue = request.params.get('rvalue') for n in b: n.val = regcal(int(n.bits_sbit),int(n.bits_ebit),int(rvalue,16)) b1.append(n) mean = mmeanings.filter(mmeanings.c.bits_id==n.id).filter(mmeanings.c.val==str(n.val)) for me1 in mean: m.append(me1) for b2 in b: m2 = mmeanings.filter(mmeanings.c.bits_id==b2.id) for m1 in m2: ms.append(m1) return {'r':r,'b1':b1,'m':m,'rvalue':rvalue,'ms':ms}