def _redirect_unauthorized(resp): if resp.status_code == 401: # We need the request for later redirecting. req = get_request() resp.headers['Location'] = url_for("auth/login", **{REDIRECT_FIELD_NAME: req.url}) resp.status_code = 302
def test_query_tracking(self): """Tests query tracking.""" client = Client(self.app, Response) response = client.get('/') request = get_request() assert len(request.sql_queries) == 2 assert response.headers['X-SQL-Query-Count'] == '2' assert response.headers['X-SQL-Query-Time'] > 0
def __init__(self): self.user = get_request().user
def redirect_gae_login_url(): req = get_request() return redirect(users.create_login_url(req.url))