def testGetHostName(self): """Tests that a correct host name is returned. """ test_data = RequestData() test_site = site.Site(link_id='test', hostname='test_host') test_data.site = test_site try: expected_host = os.environ['HTTP_HOST'] = 'some.testing.host.tld' self.assertEqual(system.getHostname(), expected_host) finally: if self.default_host is None: del os.environ['HTTP_HOST'] else: os.environ['HTTP_HOST'] = self.default_host #test a data object expected_host = 'test_host' self.assertEqual(system.getHostname(data=test_data), expected_host) test_data.site.hostname = '' try: expected_host = os.environ['HTTP_HOST'] = 'some.testing.host.tld' self.assertEqual(system.getHostname(data=test_data), expected_host) finally: if self.default_host is None: del os.environ['HTTP_HOST'] else: os.environ['HTTP_HOST'] = self.default_host
class SiteRequestHandler(RequestHandler): """Customization required by global site pages to handle HTTP requests. """ def init(self, request, args, kwargs): self.data = RequestData() self.data.populate(None, request, args, kwargs) def redirect(self, url): self.response = http.HttpResponseRedirect(url)
class SiteRequestHandler(RequestHandler): """Customization required by global site pages to handle HTTP requests. """ def init(self, request, args, kwargs): self.data = RequestData() self.redirect = RedirectHelper(self.data, self.response) self.data.populate(None, request, args, kwargs) if self.data.is_developer: self.mutator = access_checker.DeveloperMutator(self.data) self.check = access_checker.DeveloperAccessChecker(self.data) else: self.mutator = access_checker.Mutator(self.data) self.check = access_checker.AccessChecker(self.data)
def init(self, request, args, kwargs): self.data = RequestData() self.redirect = RedirectHelper(self.data, self.response) self.data.populate(None, request, args, kwargs) if self.data.is_developer: self.mutator = access_checker.DeveloperMutator(self.data) self.check = access_checker.DeveloperAccessChecker(self.data) else: self.mutator = access_checker.Mutator(self.data) self.check = access_checker.AccessChecker(self.data)
def testIsSecondaryHostName(self): """Tests if a request is from a secondary hostname. """ test_data = RequestData() test_site = site.Site(link_id='test', hostname='test_host') test_data.site = test_site try: os.environ['HTTP_HOST'] = 'some.testing.host.tld' self.assertFalse(system.isSecondaryHostname()) self.assertFalse(system.isSecondaryHostname(data=test_data)) test_data.site.hostname = "testing" self.assertTrue(system.isSecondaryHostname(data=test_data)) finally: if self.default_host is None: del os.environ['HTTP_HOST'] else: os.environ['HTTP_HOST'] = self.default_host
def init(self, request, args, kwargs): self.data = RequestData() self.data.populate(None, request, args, kwargs)