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


Python PageData.username方法代码示例

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


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

示例1: newuser

# 需要导入模块: from main import PageData [as 别名]
# 或者: from main.PageData import username [as 别名]
def newuser():
    pd = PageData();
    pd.title = "New User"

    if 'username' in session:
        flash('You are already logged in.')
        return redirect(url_for('index'))
    else:
        if request.method == 'POST':
            if not check_new_user(request):
                pd.username = request.form['username']
                pd.email = request.form['email']
                return render_template('new_user.html', pd=pd)

            if not new_user(request.form['username'], request.form['password'], request.form['email'], request.remote_addr):
                return render_template('error.html', pd=pd)

            try:
                user = SiteUser.create(request.form['username'])
                user.authenticate(request.form['password'])
                session['username'] = user.username
            except (NoUser, AuthFail):
                return render_template('error.html', pd=pd)

            flash('Welcome ' + request.form['username'])
            return redirect(url_for('index'))

        return render_template('new_user.html', pd=pd)
开发者ID:cmazuc,项目名称:scarfage,代码行数:30,代码来源:user.py

示例2: new_facebook_user

# 需要导入模块: from main import PageData [as 别名]
# 或者: from main.PageData import username [as 别名]
def new_facebook_user():
    pd = PageData();

    logger.info('Started Facebook new user for {}, referrer was {}'.format(request.remote_addr, request.referrer))

    if not check_new_user(request, nopass=True):
        pd.username = request.form['username']
        pd.email = request.form['email']
        return redirect_back(url_for('index'))

    password = ''.join(random.choice(string.printable) for _ in range(100))
    if not new_user(request.form['username'], password, request.form['email'], request.remote_addr):
        return render_template('error.html', pd=pd)

    user_key = 'oauth-facebook-{}'.format(session['facebook_id'])
    new_key(user_key, request.form['username'])

    try:
        user = SiteUser.create(request.form['username'])
        session['username'] = user.username
        profile = user.profile()
        profile.profile['facebook_id'] = session['facebook_id']
        profile.update()
    except (NoUser, AuthFail):
        return render_template('error.html', pd=pd)

    logger.info('New Facebook user {} ID {} ip {}'.format(user.username, session['facebook_id'], request.remote_addr))
    flash('Welcome ' + request.form['username'])
    return redirect(url_for('index'))
开发者ID:cmazuc,项目名称:scarfage,代码行数:31,代码来源:fbauth.py


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