<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> from google . appengine . ext import db <EOL> from google . appengine . api import memcache <EOL> class Token ( db . Model ) : <EOL> """<STR_LIT>""" <EOL> t = db . BlobProperty ( ) <EOL> def get_token ( unique_key ) : <EOL> """<STR_LIT>""" <EOL> token_string = memcache . get ( unique_key ) <EOL> if token_string is None : <EOL> token = Token . get_by_key_name ( unique_key ) <EOL> if token is None : <EOL> return None <EOL> return token . t <EOL> return token_string <EOL> def set_token ( unique_key , token_str ) : <EOL> """<STR_LIT>""" <EOL> result = memcache . set ( unique_key , token_str ) <EOL> if not result : <EOL> result = memcache . delete ( unique_key ) <EOL> if result == <NUM_LIT:0> : <EOL> return False <EOL> if Token ( key_name = unique_key , t = token_str ) . put ( ) : <EOL> return True <EOL> return None <EOL> def delete_token ( unique_key ) : <EOL> memcache . delete ( unique_key ) <EOL> Token ( key_name = unique_key ) . delete ( ) </s>
