def _get_user_country_from_profile(user):
 cache_key = u'user.{user_id}.profile.country'.format(user_id=user.id)
 profile_country = cache.get(cache_key)
 if (profile_country is None):
  profile = getattr(user, 'profile', None)
  if ((profile is not None) and (profile.country.code is not None)):
   profile_country = profile.country.code.upper()
  else:
   profile_country = ''
  cache.set(cache_key, profile_country)
 return profile_country

def _get_user_country_from_profile ( user ) : cache_key = u'user.{user_id}.profile.country' . format ( user_id = user . id ) profile_country = cache . get ( cache_key ) if ( profile_country is None ) : profile = getattr ( user , 'profile' , None ) if ( ( profile is not None ) and ( profile . country . code is not None ) ) : profile_country = profile . country . code . upper ( ) else : profile_country = '' cache . set ( cache_key , profile_country ) return profile_country
check whether the user is embargoed based on the country code in the users profile .