def _update_access_token(user, graph):
 profile = try_get_profile(user)
 model_or_profile = get_instance_for_attribute(user, profile, 'access_token')
 if model_or_profile:
  new_token = (graph.access_token != model_or_profile.access_token)
  token_message = ('a new' if new_token else 'the same')
  logger.info('found %s token %s', token_message, graph.access_token[:10])
  if new_token:
   logger.info('access token changed, updating now')
   model_or_profile.update_access_token(graph.access_token)
   model_or_profile.save()
   model_or_profile.extend_access_token()

def _update_access_token ( user , graph ) : profile = try_get_profile ( user ) model_or_profile = get_instance_for_attribute ( user , profile , 'access_token' ) if model_or_profile : new_token = ( graph . access_token != model_or_profile . access_token ) token_message = ( 'a new' if new_token else 'the same' ) logger . info ( 'found %s token %s' , token_message , graph . access_token [ : 10 ] ) if new_token : logger . info ( 'access token changed, updating now' ) model_or_profile . update_access_token ( graph . access_token ) model_or_profile . save ( ) model_or_profile . extend_access_token ( )
conditionally updates the access token in the database .