當前位置: 首頁>>代碼示例>>Python>>正文


Python User.insert方法代碼示例

本文整理匯總了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()
開發者ID:YechengZhou,項目名稱:Flask_Blog,代碼行數:14,代碼來源:RESTAPI.py

示例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()
開發者ID:dagger178,項目名稱:webApp,代碼行數:18,代碼來源:views.py

示例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
開發者ID:alphachoi,項目名稱:webApp,代碼行數:26,代碼來源:views.py


注:本文中的www.models.User.insert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。