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


Python Email.create_with_digest方法代码示例

本文整理汇总了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
开发者ID:Amstutz-IT,项目名称:formspree,代码行数:29,代码来源:views.py

示例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
开发者ID:arun-shrestha,项目名称:formspree,代码行数:20,代码来源:views.py

示例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
开发者ID:DigitalBillMusic,项目名称:formspree,代码行数:22,代码来源:views.py


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