def save_site_info(self): inputs = self.get_input() if web.ctx.method == "POST": username = inputs.get('username', '').strip() position = inputs.get('position', '').strip() case_number = inputs.get('case_number', '').strip() copy_right = inputs.get("copyright", '').strip() try: Site.update(username=username, position=position, case_number=case_number, copyright=copy_right). \ where(Site.id == 1).execute() self.private_data["update_success"] = True return web.seeother(self.make_url('home')) except Exception as e: log.error('create album failed%s' % traceback.format_exc()) self.private_data["update_success"] = False self.private_data["update_message"] = u"更新失败" return web.seeother(self.make_url('save_site_info')) if web.ctx.method == "GET": site = Site.get_or_none(Site.id == 1) self.private_data["site"] = site return self.display("admin/site_info")
def get_site_info(self): return Site.get_or_none(Site.id == 1)