Redirect Helper¶
-
class
cwf.views.redirect_address.
RedirectAddress
(request, address, relative=True, carry_get=False, ignore_get=None)[source]¶ Helper to determine where to redirect to.
- Parameters
request – Object representing current Django request.
address – String representing the address to modify into a redirect url
relative – If we should be redirecting relative to the current page we’re on
carry_get – If we should use the GET parameters from the current request in our redirect
ignore_get – List of GET parameters that should be ignored if carry_get is True
Creating the redirect¶
-
RedirectAddress.
modified
¶ Returns the result of
self.modify(unicode(self.address))
Information¶
-
RedirectAddress.
base_url
¶ Get base url from request.state if request has an attached
state
.Otherwise, return
request.META.get('SCRIPT_NAME', '')
-
RedirectAddress.
params
¶ Return dictionary of key value for GET params from
self.request
.If not
self.ignore_get
then just returnrequest.GET
Otherwise, return
request.GET
minus any values whose key is inself.ignore_get
Utility¶
-
RedirectAddress.
strip_multi_slashes
(string)[source]¶ Replace multiple slashes with single slashes in a string
-
RedirectAddress.
add_get_params
(address)[source]¶ If
self.carry_get
is False, then just return the address as is.Otherwise, urlencode the result of
params
and return a string that joins address and the parameters.
-
RedirectAddress.
joined_address
(address)[source]¶ If address is a
root_url()
, thenjoin
the address with base_url.Otherwise, if
self.relative
, thenjoin
the address withself.request.path
If the address is not a root url and
self.relative
is False, then return as is