Пример #1
0
    def AddUserToken(self, token):
        client = Client(token)
        athlete = client.get_athlete()

        # Simplified logic not to add duplicate user tokens.
        # todo: check the user is not in the user token table.
        if self.GetMemcacheToken(athlete.id) is None:
            rider = UserToken(strava_id=athlete.id, strava_token=token)
            rider.put()

            memcache.add(self.GetMemcacheKey(athlete.id), token, 60)

        return athlete.id
Пример #2
0
    def GetUserToken(self, user_id):
        token = self.GetMemcacheToken(user_id)
        if token is not None:
            return token

        rider = UserToken.query().filter(UserToken.strava_id == int(user_id)).fetch(1)
        return rider[0].strava_token if len(rider) else None