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


Python EmailForm.validate方法代码示例

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


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

示例1: reset_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate [as 别名]
def reset_email():
    if request.method == "POST":
        form = EmailForm(request.form)
        if form.validate():
            ul = serv.login(g.user['email'],form.password.data)
            if ul:
                #TODO:发送确认邮件
                try:
                    uri = serv.send_lock_request("user.confirm_email", ul.id)
                    up = g.db.query(UserProfile).filter(UserProfile.user_id==ul.id).one()
                    up.email = form.email.data
                    g.db.flush()
                    g.db.commit()
                    success = u"确认邮箱的邮件已经发出,请登录邮箱点击确认链接,然后才能使用新邮箱登陆"
                    msg = Message(u"登陆邮箱变更确认邮件", sender="[email protected]", recipients=["[email protected]"])
                    msg.html = "点击下面链接确认登陆邮件变更,点击后用新邮箱登陆爱普云平台<br/><a href=\"http://%s%s\">%s</a>"%(settings.SERVER, uri, uri)
                    g.mail.send(msg)
                except Exception, e:
                    g.db.rollback()
                    log.error(print_debug(e))
                    errors = [u"未知异常"]
            else:
                errors = [u"登陆密码输入不正确"]
        else:
            errors = [v[0] for k, v in form.errors.iteritems()]
开发者ID:romizhang,项目名称:OpenStore,代码行数:27,代码来源:views.py

示例2: save_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate [as 别名]
def save_email():
    form = EmailForm(request.form)
    if form.validate():
        db = get_db()
        db.execute('''INSERT INTO emails (email, registered)
        VALUES (?, ?)''', (request.form.get('email'), datetime.utcnow().isoformat()))
        db.commit()

        return render_template('email.html', email=Markup.escape(form.email.data))
    else:
        return redirect("/")
开发者ID:bobais,项目名称:ec,代码行数:13,代码来源:views.py

示例3: forgot_password

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate [as 别名]
def forgot_password():
    statsd.increment('api_calls.forgot_password')
    if request.method == 'POST':
        logger.info(request.form)
        form = EmailForm(request.form)
        if not form.validate():
            msg = {
                'success': False,
                'msg': form.errors, }
            return jsonify(msg)
        if secret_key != base64.b64decode(form.sig.data):
            msg = {
                'success': False,
                'msg': 'invalid signature'}
            return jsonify(msg)
        u = session.query(Person).\
            filter(Person.email == form.email.data).\
            first()
        if not u:
            msg = {
                'success': False,
                'msg': 'Email not registered!'}
            return jsonify(msg)
        m = Message(
            "Reset Password",
            recipients=[form.email.data])
        content = (
            'Click <a href="http://' +
            request.headers['Host'] + '/forgot_password?' +
            'key=' + urllib.quote(u.pw_hash) + '&email=' +
            urllib.quote(form.email.data) + '">HERE</a>' +
            ' to reset your password')
        m.html = content
        mail.send(m)
        msg = {
            'success': True,
            'msg': 'Mail Sent!'}
        return jsonify(msg)

    logger.info(request.args)
    key = urllib.unquote(request.args['key'])
    email = urllib.unquote(request.args['email'])
    u = session.query(Person).\
        filter(Person.email == email).first()
    if u and key == u.pw_hash:
        response = redirect(url_for('reset_page'))
        response.set_cookie('email', value=email)
        response.set_cookie('key', value=urllib.quote(key))
        return response
    return 'Invalid key!'
开发者ID:dhilipsiva,项目名称:moback,代码行数:52,代码来源:api.py

示例4: new_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate [as 别名]
def new_email(keyurl):
    """
    """
    key = ndb.Key(urlsafe=keyurl)
    form = EmailForm(request.form)
    if request.method == 'POST' and form.validate():
        email = EmailModel(
            enterprise = key,
            email = form.email.data
        )
        try:
            email.put()
            return redirect(url_for('admin.edit_enterprise', keyurl=keyurl))
        except CapabilityDisabledError:
            flash('save error', 'error')
    return render_template('admin/new_email.html', form=form, keyurl=keyurl)
开发者ID:AFCP,项目名称:forumhorizonchine,代码行数:18,代码来源:admin.py

示例5: edit_email

# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate [as 别名]
def edit_email(keyurl):
    email = ndb.Key(urlsafe=keyurl).get()
    if not email:
        flash('no such email', 'error')
        return redirect(url_for('admin.enterprises'))
    form = EmailForm(request.form)
    if request.method == 'GET':
        form.email.data = email.email

    if request.method == 'POST' and form.validate():
        email.email = form.email.data
        try:
            email.put()
            return redirect(url_for('admin.edit_enterprise', keyurl=email.enterprise))
        except CapabilityDisabledError:
            flash('save error', 'error')
    return render_template('admin/edit_email.html', form=form, keyurl=keyurl)
开发者ID:AFCP,项目名称:forumhorizonchine,代码行数:19,代码来源:admin.py


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