@contextmanager
def set_siteconfig_settings(settings):
 siteconfig = SiteConfiguration.objects.get_current()
 old_settings = {}
 for (setting, value) in six.iteritems(settings):
  old_settings[setting] = siteconfig.get(setting)
  siteconfig.set(setting, value)
 siteconfig.save()
 load_site_config()
 try:
  (yield)
 finally:
  for (setting, value) in six.iteritems(old_settings):
   siteconfig.set(setting, value)
  siteconfig.save()
  load_site_config()

@ contextmanager def set_siteconfig_settings ( settings ) : siteconfig = SiteConfiguration . objects . get_current ( ) old_settings = { } for ( setting , value ) in six . iteritems ( settings ) : old_settings [ setting ] = siteconfig . get ( setting ) siteconfig . set ( setting , value ) siteconfig . save ( ) load_site_config ( ) try : ( yield ) finally : for ( setting , value ) in six . iteritems ( old_settings ) : siteconfig . set ( setting , value ) siteconfig . save ( ) load_site_config ( )
a context manager to toggle site configuration settings .