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_getthen just returnrequest.GETOtherwise, return
request.GETminus 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_getis False, then just return the address as is.Otherwise, urlencode the result of
paramsand return a string that joins address and the parameters.
-
RedirectAddress.joined_address(address)[source]¶ If address is a
root_url(), thenjointhe address with base_url.Otherwise, if
self.relative, thenjointhe address withself.request.pathIf the address is not a root url and
self.relativeis False, then return as is