本文整理汇总了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'))
示例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
示例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'))