@contextmanager
def override_current_site_id(site_id):
 override_current_site_id.thread_local.site_id = site_id
 (yield)
 del override_current_site_id.thread_local.site_id

@ contextmanager def override_current_site_id ( site_id ) : override_current_site_id . thread_local . site_id = site_id ( yield ) del override_current_site_id . thread_local . site_id
context manager that overrides the current site id for code executed within it .