本文整理匯總了Python中www.models.User.insert方法的典型用法代碼示例。如果您正苦於以下問題:Python User.insert方法的具體用法?Python User.insert怎麽用?Python User.insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類www.models.User
的用法示例。
在下文中一共展示了User.insert方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from www.models import User [as 別名]
# 或者: from www.models.User import insert [as 別名]
def post(self):
t = db.select("select * from users where email=?", request.form['email'])
if t:
raise APIValueError(data=request.form['email'], message="email has already been registered")
user = User(
email=request.form['email'],
password=request.form['password'],
name=request.form['username'],
image=request.form['image'] if request.form.has_key('image') else "about:blank",
admin=1,
)
user.insert()
示例2: register
# 需要導入模塊: from www.models import User [as 別名]
# 或者: from www.models.User import insert [as 別名]
def register():
form = request.form
name = form.get('name')
user = User.get(name=name)
password = form.get('password')
if request.method == 'GET':
return render('register.html')
elif user is not None:
error = 'UserName Is Registered'
return render('register.html', error=error)
password = md5_hash(password, salt=name)
user = User(name=name, password=password)
user.insert()
return log_the_user_in()
示例3: register
# 需要導入模塊: from www.models import User [as 別名]
# 或者: from www.models.User import insert [as 別名]
def register(request):
dic = request.form
name = dic.get("name")
user = User.get(name=name)
password = dic.get("password")
error = ""
if request.method == "GET":
return render_for_response(request, "register.html")
elif user is not None:
error = "UserName Is Registered"
elif not password or not name:
error = "User Name or Password Is empty"
if error:
return render_for_response(request, "register.html", error=error)
dic["password"] = md5_hash(password, salt=name)
user = User(**dic)
user.insert()
request.status = "303 See Other"
request.header.append(("Location", "/hello"))
dic["sign"] = md5_hash(user.id + user.password)
del dic["password"]
signed_cookie[user.name] = dic["sign"]
request.set_cookie(dic)
return request