def invalidate_country_rule_cache(sender, instance, **kwargs):
 if isinstance(instance, RestrictedCourse):
  RestrictedCourse.invalidate_cache_for_course(instance.course_key)
  CountryAccessRule.invalidate_cache_for_course(instance.course_key)
 if isinstance(instance, CountryAccessRule):
  try:
   restricted_course = instance.restricted_course
  except RestrictedCourse.DoesNotExist:
   pass
  else:
   CountryAccessRule.invalidate_cache_for_course(restricted_course.course_key)

def invalidate_country_rule_cache ( sender , instance , ** kwargs ) : if isinstance ( instance , RestrictedCourse ) : RestrictedCourse . invalidate_cache_for_course ( instance . course_key ) CountryAccessRule . invalidate_cache_for_course ( instance . course_key ) if isinstance ( instance , CountryAccessRule ) : try : restricted_course = instance . restricted_course except RestrictedCourse . DoesNotExist : pass else : CountryAccessRule . invalidate_cache_for_course ( restricted_course . course_key )
invalidate cached rule information on changes to the rule models .