Пример #1
0
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
Пример #2
0
    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
Пример #3
0
 def __init__(self):
     self.user = get_request().user
Пример #4
0
def redirect_gae_login_url():
    req = get_request()
    return redirect(users.create_login_url(req.url))