def GET(self,nasid): web.header("Content-Type","text/html; charset=utf-8") db = get_db() nas = db.query(models.RadNas).get(nasid) data = dict(id=nas.id, ip_addr=nas.ip_addr, name=nas.name, auth_secret=nas.auth_secret, acct_secret=nas.acct_secret, vendor_id=nas.vendor_id, time_type=nas.time_type, status=nas.status) form = forms.nas_update_form() form.fill(data) return render("baseform.html",form=form,title="修改NAS设备",action="/nas/update/")
def POST(self,none): web.header("Content-Type","text/html; charset=utf-8") form = forms.nas_update_form() if not form.validates(): return render("baseform.html",form=form,title="修改NAS设备",action="/nas/update/") else: db = get_db() nas = db.query(models.RadNas).get(form.d.id) if not nas: return errorpage("Nas不存在") try: nas.name = form.d.name nas.auth_secret = form.d.auth_secret nas.acct_secret = form.d.acct_secret nas.vendor_id = form.d.vendor_id nas.time_type = form.d.time_type nas.status = form.d.status db.commit() db.flush() except Exception,e: db.rollback() log.error("update nas error: %s"%str(e)) return errorpage("修改Nas失败 %s"%str(e)) raise web.seeother("/nas",absolute=True)