Here are the examples of the python api werkzeug.Request.current taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Example 1
Project: solace Source File: application.py
def url_for(endpoint, **values):
"""Returns a URL for a given endpoint with some interpolation."""
external = values.pop('_external', False)
if hasattr(endpoint, 'get_url_values'):
endpoint, values = endpoint.get_url_values(**values)
request = Request.current
anchor = values.pop('_anchor', None)
assert request is not None, 'no active request'
for endpoint_choice in iter_endpoint_choices(endpoint, request.endpoint):
real_values = inject_lang_code(request, endpoint_choice, values)
if real_values is None:
continue
try:
url = request.url_adapter.build(endpoint_choice, real_values,
force_external=external)
except BuildError:
continue
view = get_view(endpoint)
if is_exchange_token_protected(view):
xt = get_exchange_token(request)
url = '%s%s_xt=%s' % (url, '?' in url and '&' or '?', xt)
if anchor is not None:
url += '#' + url_quote(anchor)
return url
raise BuildError(endpoint, values, 'GET')