Example #1
0
 def __init__(self):
     self.host_patterns = get_host_patterns()
     try:
         self.default_host = get_host(settings.DEFAULT_HOST)
     except AttributeError:
         raise ImproperlyConfigured("Missing DEFAULT_HOST setting")
     except NoReverseMatch, e:
         raise ImproperlyConfigured("Invalid DEFAULT_HOST setting: %s" % e)
Example #2
0
    def __init__(self):
        self.host_patterns = get_host_patterns()
        try:
            self.default_host = get_host(settings.DEFAULT_HOST)
        except AttributeError:
            raise ImproperlyConfigured("Missing DEFAULT_HOST setting")
        except NoReverseMatch as e:
            raise ImproperlyConfigured("Invalid DEFAULT_HOST setting: %s" % e)

        middlewares = list(settings.MIDDLEWARE_CLASSES)
        try:
            if middlewares.index(hosts_middleware) > middlewares.index(toolbar_middleware):
                raise ImproperlyConfigured(
                    "The django_hosts and debug_toolbar middlewares "
                    "are in the wrong order. Make sure %r comes before "
                    "%r in the MIDDLEWARE_CLASSES setting." % (hosts_middleware, toolbar_middleware)
                )
        except ValueError:
            # django-debug-toolbar middleware doesn't seem to be installed
            pass
Example #3
0
    def __init__(self):
        self.host_patterns = get_host_patterns()
        try:
            self.default_host = get_host(settings.DEFAULT_HOST)
        except AttributeError:
            raise ImproperlyConfigured("Missing DEFAULT_HOST setting")
        except NoReverseMatch as e:
            raise ImproperlyConfigured("Invalid DEFAULT_HOST setting: %s" % e)

        middlewares = list(settings.MIDDLEWARE_CLASSES)
        try:
            if (middlewares.index(hosts_middleware) >
                    middlewares.index(toolbar_middleware)):
                raise ImproperlyConfigured(
                    "The django_hosts and debug_toolbar middlewares "
                    "are in the wrong order. Make sure %r comes before "
                    "%r in the MIDDLEWARE_CLASSES setting." %
                    (hosts_middleware, toolbar_middleware))
        except ValueError:
            # django-debug-toolbar middleware doesn't seem to be installed
            pass
Example #4
0
 def test_appended_patterns(self):
     self.assertEqual(get_host('special').name, 'special')
Example #5
0
 def test_get_host(self):
     self.assertEqual(get_host('static').name, 'static')
     self.assertRaisesWithMessage(NoReverseMatch,
         "No host called 'non-existent' exists", get_host, 'non-existent')
Example #6
0
 def _get_site_and_host(self):
     self._site = Site.objects.get(domain=self._domain)
     self._host = get_host(self._domain)
Example #7
0
 def test_appended_patterns(self):
     self.assertEqual(get_host('special').name, 'special')
Example #8
0
 def test_get_host(self):
     self.assertEqual(get_host('static').name, 'static')
     self.assertRaisesWithMessage(NoReverseMatch,
         "No host called 'non-existent' exists", get_host, 'non-existent')
Example #9
0
 def setUp(self):
     set_urlconf(get_host('data').urlconf)
Example #10
0
 def setUp(self):
     set_urlconf(get_host('data').urlconf)