def process_response(self, request, response): if hasattr(request, settings.LANDLORD_DEFAULT_NAMESPACE_KEY): namespace = getattr(request, settings.LANDLORD_DEFAULT_NAMESPACE_KEY) if namespace: landlord.pop() return response # def process_exception(self, request, exception): # if isinstance(exception, TenantNotFound): # if self.tenant_not_found_handler: # self.tenant_not_found_handler(request, exception)
def __exit__(self, type, value, tb): landlord.pop()
def test_basic(self): random_str = randomStr(24) landlord.push(random_str) self.assertEqual(landlord.get_current_namespace(), random_str) landlord.pop() self.assertEqual(landlord.get_current_namespace(), None)