当前位置: 首页>>代码示例>>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;未经允许,请勿转载。