def logged_in_bingo_identity(): if request_cache.cache.get(LOGGED_IN_IDENTITY_CACHE_KEY) is None: request_cache.cache[ LOGGED_IN_IDENTITY_CACHE_KEY] = config.current_logged_in_identity( ) return request_cache.cache[LOGGED_IN_IDENTITY_CACHE_KEY]
def put_id_if_necessary(): """To be called at the end of a request. Check to see if we should put() the gae_bingo_identity, and put() it if so. """ id_to_put = request_cache.cache.get(ID_TO_PUT_CACHE_KEY) if id_to_put: val = config.current_logged_in_identity() if val is None: return if isinstance(val, GAEBingoIdentityModel): if val.gae_bingo_identity and id_to_put != val.gae_bingo_identity: logging.warning( "val.gae_bingo_identity got set to %s unexpectedly," "but id_to_put is %s" % (val.gae_bingo_identity, id_to_put)) else: # If the UserData has been updated in the course of this # request current_logged_in_identity might read a stale version # of the UserData from the request_cache. In order to make # sure we have the latest userData we will get the the userData # again. val = db.get(val.key()) val.gae_bingo_identity = id_to_put val.put() # Flush the transaction so the HR datastore doesn't suffer from # eventual consistency issues when next grabbing this UserData. db.get(val.key())
def logged_in_bingo_identity(): if request_cache.cache.get(LOGGED_IN_IDENTITY_CACHE_KEY) is None: request_cache.cache[LOGGED_IN_IDENTITY_CACHE_KEY] = config.current_logged_in_identity() return request_cache.cache[LOGGED_IN_IDENTITY_CACHE_KEY]