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


Python OAuthSignIn.generateRandomUsername方法代码示例

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


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

示例1: oauth_callback

# 需要导入模块: from oauth import OAuthSignIn [as 别名]
# 或者: from oauth.OAuthSignIn import generateRandomUsername [as 别名]
def oauth_callback():
    try:
        auth = OAuthSignIn(app)
        return auth.callback()
    except Exception as e:
        print e
        auth = OAuthSignIn(app)
        session['username'] = auth.generateRandomUsername()
        session['isAnonymous'] = True
        return redirect(url_for('home'))
开发者ID:jmsaucier,项目名称:trs,代码行数:12,代码来源:routes.py

示例2: recommend

# 需要导入模块: from oauth import OAuthSignIn [as 别名]
# 或者: from oauth.OAuthSignIn import generateRandomUsername [as 别名]
def recommend():
    try:
        #if user is not logged in or does not have a random username assigned, then we should give them one
        if((not 'username' in session) or session['username'] == '' or (not 'isAnonymous' in session)):
            auth = OAuthSignIn(app)
            session['username'] = auth.generateRandomUsername()
            session['isAnonymous'] = True


        _recommendations = twitchrecommender.generateRecommendationListForUser(session['username'], session['isAnonymous'])


        twitchrecommender.storeFollowerRecommendations(session['username'],_recommendations)
        session['rec_time_out'] = time.time() + 900
        session['dir'] = 'up'
        return redirect(url_for('recommendations', rank=1))
    except Exception as e:

        print e, 'B', sys.exc_traceback.tb_lineno
开发者ID:jmsaucier,项目名称:trs,代码行数:21,代码来源:routes.py

示例3: home

# 需要导入模块: from oauth import OAuthSignIn [as 别名]
# 或者: from oauth.OAuthSignIn import generateRandomUsername [as 别名]
def home():

    if( not 'isAnonymous' in session):
        if('oauth_access_token' in session and session['oauth_access_token'] != ''):
            session['isAnonymous'] = False
        else:
            auth = OAuthSignIn(app)
            #random username used for recommendation storage
            session['username'] = auth.generateRandomUsername()
            session['isAnonymous'] = True

    if ('oauth_access_token' in session and session['oauth_access_token'] != '') or ('isAnonymous' in session and session['isAnonymous'] == False):
        try:
            return render_template('index.jade',title = 'Home Page',year = datetime.now().year, username=session['username'], isAnonymous = session['isAnonymous'])
        except Exception as e:
            print e, 'A'
    else:
        try:
            return render_template('index.jade',title = 'Home Page',year = datetime.now().year, username='', isAnonymous = session['isAnonymous'])

        except Exception as e:
            print e, 'C'
            return redirect(url_for('error'))
开发者ID:jmsaucier,项目名称:trs,代码行数:25,代码来源:routes.py


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