コード例 #1
0
 def lookup_nonce(self, oauth_consumer, oauth_token, nonce):
     
     if oauth_token is None:
         return None
     
     logger.warning("!!! In GAEOAuthDataStore.lookup_nonce  key_:%s, consumer_key: %s, token_key:%s"%(nonce,oauth_consumer.key_,oauth_token.key_))
     
     nonces = Nonce.all()\
         .filter('consumer_key =',oauth_consumer.key_)\
         .filter('token_key =',oauth_token.key_)\
         .filter('key_ =',nonce).fetch(1000)
     
     if len(nonces) == 1:
         nonce = nonces[0]
         return nonce.key_
     elif len(nonces) == 0:
         #create a nonce
         nonce_obj = Nonce(consumer_key=oauth_consumer.key_, 
             token_key=oauth_token.key_,
             key_=nonce)
         nonce_obj.put()
         return None
     else:
         raise Exception('More then one nonce matches consumer_key "%s", \
             token_key "%s", key_ "%S"'%(oauth_consumer.key,oauth_token.key, nonce))