Here are the examples of the python api flask.request._get_current_object taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
8 Examples
3
View Complete Implementation : nplusone.py
Copyright Apache License 2.0
Author : getsentry
Copyright Apache License 2.0
Author : getsentry
def get_worker():
try:
return request._get_current_object()
except RuntimeError:
return None
3
View Complete Implementation : test_testing.py
Copyright MIT License
Author : jest-community
Copyright MIT License
Author : jest-community
def test_session_transactions_keep_context(app, client, req_ctx):
rv = client.get('/')
req = flask.request._get_current_object()
astert req is not None
with client.session_transaction():
astert req is flask.request._get_current_object()
3
View Complete Implementation : __init__.py
Copyright GNU General Public License v3.0
Author : mutschler
Copyright GNU General Public License v3.0
Author : mutschler
def process_request(self):
g.debug_toolbar = self
if not self._show_toolbar():
return
real_request = request._get_current_object()
self.debug_toolbars[real_request] = DebugToolbar(real_request, self.jinja_env)
for panel in self.debug_toolbars[real_request].panels:
panel.process_request(real_request)
3
View Complete Implementation : __init__.py
Copyright GNU General Public License v3.0
Author : mutschler
Copyright GNU General Public License v3.0
Author : mutschler
def process_view(self, app, view_func, view_kwargs):
""" This method is called just before the flask view is called.
This is done by the dispatch_request method.
"""
real_request = request._get_current_object()
if real_request in self.debug_toolbars:
for panel in self.debug_toolbars[real_request].panels:
new_view = panel.process_view(real_request, view_func, view_kwargs)
if new_view:
view_func = new_view
return view_func
3
View Complete Implementation : api_utils.py
Copyright GNU General Public License v3.0
Author : naturalness
Copyright GNU General Public License v3.0
Author : naturalness
def determine_user_agent_facing_host():
"""
Determines the host for the active request as seen by the User-Agent
(client), astuming proxies along the way have been being truthful.
"""
# Request is a proxy object, and cannot be weakly-referenced; instead,
# get a reference to true object.
true_request = request._get_current_object()
if true_request in HOST_CACHE:
return HOST_CACHE[true_request]
else:
host = calculate_user_agent_facing_host()
HOST_CACHE[true_request] = host
return host
3
View Complete Implementation : flask.py
Copyright MIT License
Author : spoqa
Copyright MIT License
Author : spoqa
def get_session(self):
ctx = request._get_current_object()
try:
session = ctx._current_session
except AttributeError:
return None
else:
return session
0
View Complete Implementation : __init__.py
Copyright GNU General Public License v3.0
Author : mutschler
Copyright GNU General Public License v3.0
Author : mutschler
def process_response(self, response):
real_request = request._get_current_object()
if real_request not in self.debug_toolbars:
return response
# Intercept http redirect codes and display an html page with a
# link to the target.
if current_app.config['DEBUG_TB_INTERCEPT_REDIRECTS']:
if (response.status_code in self._redirect_codes and
not real_request.is_xhr):
redirect_to = response.location
redirect_code = response.status_code
if redirect_to:
content = self.render('redirect.html', {
'redirect_to': redirect_to,
'redirect_code': redirect_code
})
response.content_length = len(content)
response.location = None
response.response = [content]
response.status_code = 200
# If the http response code is 200 then we process to add the
# toolbar to the returned html response.
if (response.status_code == 200 and
response.headers['content-type'].startswith('text/html')):
for panel in self.debug_toolbars[real_request].panels:
panel.process_response(real_request, response)
if response.is_sequence:
response_html = response.data.decode(response.charset)
toolbar_html = self.debug_toolbars[real_request].render_toolbar()
content = replace_insensitive(
response_html, '</body>', toolbar_html + '</body>')
content = content.encode(response.charset)
response.response = [content]
response.content_length = len(content)
return response
0
View Complete Implementation : __init__.py
Copyright GNU General Public License v3.0
Author : mutschler
Copyright GNU General Public License v3.0
Author : mutschler
def teardown_request(self, exc):
self.debug_toolbars.pop(request._get_current_object(), None)