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


Python User.save方法代码示例

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


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

示例1: test_get_by_id

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import save [as 别名]
    def test_get_by_id(self):
        """Get user by ID."""
        user = User('foo', '[email protected]')
        user.save()

        retrieved = User.get_by_id(user.id)
        assert retrieved == user
开发者ID:iulian4ik,项目名称:HeroesOfProgramming,代码行数:9,代码来源:test_models.py

示例2: register

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import save [as 别名]
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data,
                    password=form.password.data)

        user.save()
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html', form=form)
开发者ID:XiongZhijun,项目名称:simple-flask,代码行数:11,代码来源:views.py

示例3: create_user

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import save [as 别名]
def create_user():
    email = request.form.get('email')
    name = request.form.get('name')

    if not email or not name:
        abort(400)

    try:
        user = User.objects().get(email=email)
    except DoesNotExist:
        user = User(email=email, name=name)
        user.save()
    except MultipleObjectsReturned:
        abort(500)
    except NotUniqueError:
        abort(203)

    resp = {'user': user.dict()}
    return jsonify(resp)
开发者ID:schlosser,项目名称:go-to-sleep,代码行数:21,代码来源:routes.py

示例4: create_admin_user

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import save [as 别名]
def create_admin_user(username, password):
    """Creates the administrator user.
    Returns the created admin user.

    :param username: The username of the user.

    :param password: The password of the user.
    """

    user = User.query.filter_by(username=username).first()
    if user:
        return user
    user = User()

    role = Role.query.filter_by(permissions=Permission.ADMINISTER).first()
    user.role = role
    user.username = username
    user.password = password

    user.save()
    return user
开发者ID:XiongZhijun,项目名称:simple-flask,代码行数:23,代码来源:populate.py

示例5: test_password_is_nullable

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import save [as 别名]
 def test_password_is_nullable(self):
     user = User(username='foo', email='[email protected]')
     user.save()
     assert user.password is None
开发者ID:gabeos,项目名称:docker-flask-template,代码行数:6,代码来源:test_models.py

示例6: test_created_at_defaults_to_datetime

# 需要导入模块: from app.user.models import User [as 别名]
# 或者: from app.user.models.User import save [as 别名]
 def test_created_at_defaults_to_datetime(self):
     user = User(username='foo', email='[email protected]')
     user.save()
     assert bool(user.created_at)
     assert isinstance(user.created_at, dt.datetime)
开发者ID:gabeos,项目名称:docker-flask-template,代码行数:7,代码来源:test_models.py


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