def render(self, context):
     url = self.baseObject.render(context)
     
     # Make the URL absolute
     root_url = getattr(settings, "ROOT_URL", None)
     if not root_url:
         raise ValueError("Config setting 'ROOT_URL' must be defined, and must be the sites root url")
     
     root_url = root_url.rstrip("/")
     url = get_hashed_url(root_url + url)
     
     return url
Example #2
0
    def render(self, context):
        url = self.baseObject.render(context)

        # Make the URL absolute
        root_url = getattr(settings, "ROOT_URL", None)
        if not root_url:
            raise ValueError(
                "Config setting 'ROOT_URL' must be defined, and must be the sites root url"
            )

        root_url = root_url.rstrip("/")
        url = get_hashed_url(root_url + url)

        return url
Example #3
0
 def handle(self, *args, **options):
     for url in args:
         print get_hashed_url(url)
Example #4
0
 def test_is_valid_url_bad_hash(self):
     url = utilities.get_hashed_url(
         self.url,
         datetime.datetime.now() + datetime.timedelta(days=10))
     url += "xxx"
     self.assertFalse(utilities.is_valid_url(url))
Example #5
0
 def test_is_valid_url_expired(self):
     url = utilities.get_hashed_url(
         self.url,
         datetime.datetime.now() + datetime.timedelta(days=-10))
     self.assertFalse(utilities.is_valid_url(url))
Example #6
0
 def test_is_valid_url_no_time(self):
     url = utilities.get_hashed_url(self.url)
     self.assertFalse(utilities.is_valid_url(url))
Example #7
0
 def test_is_valid_url_ok(self):
     url = utilities.get_hashed_url(
         self.url,
         datetime.datetime.now() + datetime.timedelta(days=10))
     self.assertTrue(utilities.is_valid_url(url))
Example #8
0
 def test_get_hashed_url_with_datetime(self):
     url = utilities.get_hashed_url(
         self.url, datetime.datetime(2011, 6, 1, 9, 33, 22, 441717))
     expected = "https://moo.com:88/mooo/cow/?xx=yy&aa=bb&_t=1306920802&_h=effefe2db031944bee6b79943db24badf7f968fe"
     self.assertEqual(url, expected)
Example #9
0
 def test_get_hashed_url_with_time(self):
     url = utilities.get_hashed_url(self.url, 123)
     expected = "https://moo.com:88/mooo/cow/?xx=yy&aa=bb&_t=123&_h=839201dc174753d0099e3669a5841b94ddecb393"
     self.assertEqual(url, expected)
Example #10
0
 def test_get_hashed_url_no_time(self):
     url = utilities.get_hashed_url(self.url)
     expected = "https://moo.com:88/mooo/cow/?xx=yy&aa=bb&_t=&_h=47f37d04c98a06a0c45790e0af2a1fd64129dfb2"
     self.assertEqual(url, expected)
Example #11
0
 def handle(self, *args, **options):
     for url in args:
         print get_hashed_url(url)