def __init__(self, redirect_to): #TODO: someday extend to language switching via extra argument if len(redirect_to) > 0 and redirect_to[0] == "/": lang = translation.get_language() path = "/%s%s" % (lang, redirect_to) else: path = redirect_to HttpResponseRedirect.__init__(self, path)
def __init__(self, redirect_to, msg): HttpResponseRedirect.__init__(self, redirect_to) if msg: # We just keep the message two seconds. max_age = 2 expires_time = time.time() + max_age expires = cookie_date(expires_time) self.set_cookie("message", lfs_quote(msg), max_age=max_age, expires=expires)
def __init__(self, redirect_to, msg): HttpResponseRedirect.__init__(self, redirect_to) if msg: # We just keep the message two seconds. max_age = 2 expires_time = time.time() + max_age expires = cookie_date(expires_time) self.set_cookie("message", lfs_quote(msg), max_age=max_age, expires=expires)
def test_invalid_redirect_repr(self): """ If HttpResponseRedirect raises DisallowedRedirect, its __repr__() should work (in the debug view, for example). """ response = HttpResponseRedirect.__new__(HttpResponseRedirect) with self.assertRaisesMessage(DisallowedRedirect, "Unsafe redirect to URL with protocol 'ssh'"): HttpResponseRedirect.__init__(response, 'ssh://foo') expected = '<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="ssh://foo">' self.assertEqual(repr(response), expected)
def __init__(self, redirect_to, msg): HttpResponseRedirect.__init__(self, redirect_to) if msg: # We just keep the message two seconds. max_age = 2 expires = datetime.datetime.strftime( datetime.datetime.utcnow() + datetime.timedelta(seconds=max_age), "%a, %d-%b-%Y %H:%M:%S GMT") self.set_cookie("message", lfs_quote(msg), max_age=max_age, expires=expires)
def test_invalid_redirect_repr(self): """ If HttpResponseRedirect raises DisallowedRedirect, its __repr__() should work (in the debug view, for example). """ response = HttpResponseRedirect.__new__(HttpResponseRedirect) with self.assertRaisesMessage(DisallowedRedirect, "Unsafe redirect to URL with protocol 'ssh'"): HttpResponseRedirect.__init__(response, 'ssh://foo') expected = '<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="ssh://foo">' self.assertEqual(repr(response), expected)
def __init__(self, redirect_to, **kwargs): self.url = redirect_to self.process_notices(kwargs) HttpResponseRedirect.__init__(self, self.url)
def __init__(self, redirect_to, **kwargs): self.url = redirect_to self.process_notices(kwargs) HttpResponseRedirect.__init__(self, self.url)
def __init__(self, view, *args, **kwargs): viewurl = reverse(view, args=args, kwargs=kwargs) HttpResponseRedirect.__init__(self, viewurl)
def __init__(self, urn): self.urn = urn return HttpResponseRedirect.__init__(self, resolve_urn(urn))
def __init__(self, request, redirect_to): HttpResponseRedirect.__init__(self, redirect_to) try: forwarded_host = 'http://' + request.META['HTTP_X_FORWARDED_HOST'] except: forwarded_host = 'http://%s' % (request.get_host().replace('*', 'www')) self['Location'] = forwarded_host + self['Location']
def __init__(self, view, *args, **kwargs): viewurl = reverse(view, args=args, kwargs=kwargs) HttpResponseRedirect.__init__(self, viewurl)
def __init__(self, redirect_to, request=None): if request is not None and request.is_ajax: redirect_to += ('&', '?')[redirect_to[-1] is '/'] + 'is_ajax=1' HttpResponseRedirect.__init__(self, redirect_to)