def POST(self): input = web.input(id=None, passwd=None, role=None) if input.id is not None and input.passwd is not None and input.role is not None: role = input.role id = input.id passwd = input.passwd else: #invaild input return render.index(auth_fail_code=3) try: id_from_db = db.select(role, {"id":id}, where="id=$id")[0] except Exception, e: #there isn`t username ,code 2 return render.index(auth_fail_code=1)
def GET(self): #get year & month years = time.strftime("%Y") month = time.strftime("%m") #user hasn`t login if web.ctx.session.user_info is None: raise web.seeother("/") user_info = web.ctx.session.user_info #:-( fees_list = db.select( "fees", {"id":user_info["id"], "years":years, "month":month}, what="name, sum, status", where="user_id=$id and years=$years and month=$month" ) return render.fees(title=u"缴费信息", id=id, years=years, month=month, fees_list=fees_list)
def GET(self): message_list = db.select("message") return render.message_list(title=u" 留言列表", message_list=message_list)
def GET(self): worker_no = 0 troub_list = db.select("trouble") return render.trouble_list(title=u"维护人员页面", troub_list=troub_list, worker_no=worker_no)
from os import path from sys import exit, stderr, path as pythonpath from datetime import datetime, timedelta # Import db model from PROJECT_ROOT parentdir = path.dirname(path.dirname(path.abspath(__file__))) pythonpath.insert(0,parentdir) import model from model import db # Delete any old phrases starting from right now. now = datetime.now() try: rows = db.select('stash', order='id asc') except: raise for row in rows: maxdays = row.get('maxdays') created = row.get('created') seqID = row.get('id') delta = now-created if maxdays < delta.days: try: model.delete_phrase(seqID) except: raise