Beispiel #1
0
def _get_host(request=None):
    if request is None:
        if 'airavata.middleware.ThreadLocalMiddleware' in settings.MIDDLEWARE_CLASSES:
            from threadlocals.threadlocals import get_thread_variable
            host = get_thread_variable('requested_host')
            if host is None:
                raise NoRequestFound("HostName could not be retrieved")
            return host
        else:
            raise ImproperlyConfigured(
                "You should either provide a request or install threadlocals")
    domain_host, domain_port = split_domain_port(request.get_host())
    return domain_host
Beispiel #2
0
 def test_get_set_thread_variable(self):
     set_thread_variable('test', {'test': 'test'})
     gotten = get_thread_variable('test')
     self.assertEqual(gotten, {'test': 'test'})
Beispiel #3
0
 def test_get_set_thread_variable(self):
     set_thread_variable('test', { 'test': 'test'})
     gotten = get_thread_variable('test')
     self.assertEqual(gotten, { 'test': 'test'})
Beispiel #4
0
 def test_get_thread_variable_default(self):
     gotten = get_thread_variable('unset', 'default value')
     self.assertEqual(gotten, 'default value')
Beispiel #5
0
 def test_get_thread_variable_default(self):
     gotten = get_thread_variable('unset', 'default value')
     self.assertEqual(gotten, 'default value')