本文整理汇总了Python中pybossa.model.user.User.info['facebook_token']方法的典型用法代码示例。如果您正苦于以下问题:Python User.info['facebook_token']方法的具体用法?Python User.info['facebook_token']怎么用?Python User.info['facebook_token']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybossa.model.user.User
的用法示例。
在下文中一共展示了User.info['facebook_token']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: manage_user
# 需要导入模块: from pybossa.model.user import User [as 别名]
# 或者: from pybossa.model.user.User import info['facebook_token'] [as 别名]
def manage_user(access_token, user_data):
"""Manage the user after signin"""
user = user_repo.get_by(facebook_user_id=user_data['id'])
facebook_token = dict(oauth_token=access_token)
if user is None:
info = dict(facebook_token=facebook_token)
name = username_from_full_name(user_data['name'])
user_exists = user_repo.get_by_name(name) is not None
# NOTE: Sometimes users at Facebook validate their accounts without
# registering an e-mail (see this http://stackoverflow.com/a/17809808)
email_exists = (user_data.get('email') is not None and
user_repo.get_by(email_addr=user_data['email']) is not None)
if not user_exists and not email_exists:
if not user_data.get('email'):
user_data['email'] = name
user = User(fullname=user_data['name'],
name=name,
email_addr=user_data['email'],
facebook_user_id=user_data['id'],
info=info)
user_repo.save(user)
if newsletter.is_initialized() and user.email_addr != name:
newsletter.subscribe_user(user)
return user
else:
return None
else:
user.info['facebook_token'] = facebook_token
user_repo.save(user)
return user