本文整理汇总了Python中User.save方法的典型用法代码示例。如果您正苦于以下问题:Python User.save方法的具体用法?Python User.save怎么用?Python User.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_by_id
# 需要导入模块: import User [as 别名]
# 或者: from 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
示例2: login
# 需要导入模块: import User [as 别名]
# 或者: from User import save [as 别名]
def login(provider_name):
response = make_response()
result = current_app.authomatic.login(
WerkzeugAdapter(request, response), provider_name
)
if result:
if result.user:
first_login = False
result.user.update()
user = User.objects(provider=provider_name, user_id=result.user.id).first()
if user is None:
user = User(
username=result.user.username,
email=result.user.email,
name=result.user.name,
user_id=result.user.id,
provider=provider_name
)
user.save()
first_login = True
else:
user.name = result.user.name
user.email = result.user.email
user.save()
session['user_id'] = user.user_id
return redirect_next()
flash_error('Authentication failed')
return redirect(url_for('auth.login_page', next=request.path))
return response
示例3: test_password_is_nullable
# 需要导入模块: import User [as 别名]
# 或者: from User import save [as 别名]
def test_password_is_nullable(self):
user = User(username='foo', email='[email protected]')
user.save()
assert user.password is None
示例4: test_created_at_defaults_to_datetime
# 需要导入模块: import User [as 别名]
# 或者: from 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)