def get_rate(source_currency, target_currency): rate = None if CACHE_ENABLED: rate = get_rate_cached(source_currency, target_currency) if not rate: rate = ExchangeRate.objects.get_rate(source_currency, target_currency) return rate