appengine.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:gdata-python3 作者: dvska 项目源码 文件源码
def save_auth_tokens(token_dict, user=None):
    """Associates the tokens with the current user and writes to the datastore.

    If there us no current user, the tokens are not written and this function
    returns None.

    Returns:
      The key of the datastore entity containing the user's tokens, or None if
      there was no current user.
    """
    if user is None:
        user = users.get_current_user()
    if user is None:
        return None
    memcache.set('gdata_pickled_tokens:%s' % user, pickle.dumps(token_dict))
    user_tokens = TokenCollection.all().filter('user =', user).get()
    if user_tokens:
        user_tokens.pickled_tokens = pickle.dumps(token_dict)
        return user_tokens.put()
    else:
        user_tokens = TokenCollection(
            user=user,
            pickled_tokens=pickle.dumps(token_dict))
        return user_tokens.put()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号