Esempio n. 1
0
 def get(self):
     session = get_current_session()        
     frob = self.request.get('frob') 
     if not frob:
         self.response.out.write("no frob")
         return
     
     nickname = session.get("nickname", 0)
     if not nickname:
         self.response.out.write("no nickname")
         return
     userinfo = UserInfo.gql("WHERE nickname=:1", nickname).get()
     if not userinfo:
         self.response.out.write("no user")
         return
          
     flickr_api_key = userinfo.flickr_api_key
     flickr_api_secret = userinfo.flickr_api_secret
     flickr = flickrapi.FlickrAPI(
                 flickr_api_key, 
                 flickr_api_secret, 
                 store_token=False)
         
     try:
         token = flickr.get_token(frob)
         e = TokenEntity.gql("WHERE nickname=:1", nickname).get()
         if not e:
             e = TokenEntity()
         e.username = nickname
         e.token = token
         e.put()
         #session['flickr_token'] = token
     except Exception as e:
         print "Unexpected error:", e.message
     self.redirect('/setting')
Esempio n. 2
0
    def set_cached_token(self, token):
        """Cache a token for later use."""

        # Remember for later use
        self.memory[self.username] = token

        name = self.getUsername()
        
        entities = TokenEntity.gql("WHERE username:="******""
        for entity in entities:
            e = entity
            break
        if not e:
            e = TokenEntity()
        print "eeeeeeeeee"
        e.apikey = self.api_key
        e.username = username
        e.token = token
        e.put()
        print "xxxxxxxxxxxxxxx"