Refactor templates and added url_for_security utility. Can also configure the blueprint name.

This commit is contained in:
Matt Wright
2012-08-16 13:41:13 -04:00
parent ac674ecd86
commit 2fcfb80e8e
23 changed files with 83 additions and 61 deletions
+15
View File
@@ -115,6 +115,21 @@ def get_url(endpoint_or_url):
return endpoint_or_url
def url_for_security(endpoint, **values):
"""Return a URL for the security blueprint
:param endpoint: the endpoint of the URL (name of the function)
:param values: the variable arguments of the URL rule
:param _external: if set to `True`, an absolute URL is generated. Server
address can be changed via `SERVER_NAME` configuration variable which
defaults to `localhost`.
:param _anchor: if provided this is added as anchor to the URL.
:param _method: if provided this explicitly specifies an HTTP method.
"""
endpoint = '%s.%s' % (_security.blueprint_name, endpoint)
return url_for(endpoint, **values)
def get_post_login_redirect():
"""Returns the URL to redirect to after a user logs in successfully."""
return (get_url(request.args.get('next')) or