当前位置: 首页>>代码示例>>Python>>正文


Python User.insert方法代码示例

本文整理汇总了Python中model.User.insert方法的典型用法代码示例。如果您正苦于以下问题:Python User.insert方法的具体用法?Python User.insert怎么用?Python User.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.User的用法示例。


在下文中一共展示了User.insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import insert [as 别名]
def register_user():
    i = ctx.request.input(name='',email='', password='')
    name = i.name.strip()
    email = i.email.strip()
    password = i.password
    if not name:
        raise APIValueError('name')
    if not email or not email_valid(email):
        raise APIValueError('email')
    if not password or not password_valid(password):
        raise APIValueError('password')

    user = User.find_first('where email=?', email)
    if user:
        raise APIError('registered failed', 'email', 'Email is already in use')

    user = User(name = name, email = email, password = password, image = 'about:blank')
    user.insert()
    return user
开发者ID:FlyingHorse,项目名称:docker-python-webapp,代码行数:21,代码来源:urls.py

示例2: user_register

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import insert [as 别名]
def user_register(email, password, username, captcha, answer):
    '''
    Register a user. And if success it will be logged in automatically.
    '''
    if answer.lower() != captcha.lower():
        raise APIValueError('captcha', 'Wrong Captcha - ' + captcha)
    if not username:
        raise APIValueError('username', message="Username cannot be empty.")
    if not email or not _RE_EMAIL.match(email):
        raise APIValueError('email', message="Email cannot be empty.")
    if not password or not _RE_MD5.match(password):
        raise APIValueError('password', message="Invalid Hashvalue")
    user = User.find_first('where t_emailaddr=?', email)
    if user:
        raise APIValueError('email', message="EMail is already in use.")
    # Write to database
    user = User(username=username, email=email, password=password,
                avatar='/resources/images/user_default.gif', creation_time=time.time())
    current_user = user.insert()
    # Login as registered user.
    cookie = make_signed_cookie(str(current_user['t_uid']), user.password, None)
    ctx.response.set_cookie(_COOKIE_NAME, cookie)
    return current_user
开发者ID:excelle08,项目名称:Umbrella,代码行数:25,代码来源:auth.py

示例3: User

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import insert [as 别名]
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import logging
logging.basicConfig(format='%(levelname)s:%(message)s',level='INFO')

from model import User,Blog,Comment
import db

db.create_engine(user='root',password='123456',database='myblog')

u = User(name = 'Test',email='[email protected]',password='123456',image='about:blank')

u.insert()

print 'new user id:',u.id
u1 = User.find_first('where email=?',['[email protected]'])
print 'find user\'s name:',u1.name
开发者ID:flylixiaolong,项目名称:webblog,代码行数:20,代码来源:test_db.py

示例4: insert

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import insert [as 别名]
def insert():
    from model import User
    mongo = User()
    mongo.insert({"id": 1, "name": "meego"})
开发者ID:chu888chu888,项目名称:Python-Tornado-diggit,代码行数:6,代码来源:test.py

示例5: test_insert

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import insert [as 别名]
def test_insert(loop):
	user = User(id = '111',name = 'aaa',email='[email protected]', passwd='1234567890', image='about:blank')
	yield from create_pool(loop,**kw)
	yield from user.insert()
	print('insert')
开发者ID:hcjjy,项目名称:python_webapp,代码行数:7,代码来源:ormTest.py


注:本文中的model.User.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。