本文整理汇总了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