本文整理汇总了Python中models.Email.create_with_digest方法的典型用法代码示例。如果您正苦于以下问题:Python Email.create_with_digest方法的具体用法?Python Email.create_with_digest怎么用?Python Email.create_with_digest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Email
的用法示例。
在下文中一共展示了Email.create_with_digest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_email
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import create_with_digest [as 别名]
def confirm_email(digest):
res = redirect(url_for('account'))
email = Email.create_with_digest(addr=request.args.get('email', ''),
user_id=current_user.id,
digest=digest)
if email:
try:
DB.session.add(email)
DB.session.commit()
pending = request.cookies.get('pending-emails', '').split(',')
try:
pending.remove(email.address)
except ValueError:
pass # when not in list, means nothing serious.
res.set_cookie('pending-emails', ','.join(pending), max_age=10800)
flash(u'{} confirmed.'.format(
email.address), 'success')
except IntegrityError as e:
g.log.error('Failed to save new email address to account.',
exception=repr(e))
flash(u'A unexpected error has ocurred while we were trying '
'to confirm the email. Please contact us if this continues '
'to happen.', 'error')
return res
else:
flash(u"Couldn't confirm {}. Wrong link.".format(email), 'error')
return res
示例2: confirm_email
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import create_with_digest [as 别名]
def confirm_email(digest):
res = redirect(url_for('account'))
email = Email.create_with_digest(addr=request.args.get('email', ''),
user_id=current_user.id,
digest=digest)
if email:
try:
DB.session.add(email)
DB.session.commit()
pending = request.cookies.get('pending-emails', '').split(',')
pending.remove(email.address)
res.set_cookie('pending-emails', ','.join(pending), max_age=10800)
flash('%s confirmed.' % email.address, 'success')
except IntegrityError:
return res
else:
flash('Couldn\'t confirm %s. Wrong link.' % email, 'error')
return res
示例3: confirm_email
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import create_with_digest [as 别名]
def confirm_email(digest):
res = redirect(url_for('account'))
email = Email.create_with_digest(addr=request.args.get('email', ''),
user_id=current_user.id,
digest=digest)
if email:
try:
DB.session.add(email)
DB.session.commit()
pending = request.cookies.get('pending-emails', '').split(',')
pending.remove(email.address)
res.set_cookie('pending-emails', ','.join(pending), max_age=10800)
flash('%s confirmed.' % email.address, 'success')
except IntegrityError as e:
g.log.error('Failed to save new email address to account.', exc_info=e)
flash('A unexpected error has ocurred while we were trying to confirm the email. Please contact us if this continues to happen.', 'error')
return res
else:
flash('Couldn\'t confirm %s. Wrong link.' % email, 'error')
return res