예제 #1
0
 def session(self):
     """Get current glashammer/securecookie session"""
     # TODO: This has to be refactored! This is in Request, too!
     req = get_request()
     if 'beaker.session' in req.environ:
         return req.environ['beaker.session']
     else:
         return get_session()
예제 #2
0
def add_query_debug_headers(response):
    """Add headers with the SQL info."""
    request = get_request()

    if settings['database/track_queries']:
        count = len(request.sql_queries)
        sql_time = 0.0
        for stmt, param, time in request.sql_queries:
            sql_time += time
        response.headers['X-SQL-Query-Count'] = str(count)
        response.headers['X-SQL-Query-Time'] = str(sql_time)
예제 #3
0
def request_track_query(cursor, statement, parameters, time):
    """If there is an active request, it logs the query on it."""
    if settings['database/track_queries']:
        # It's possible we're not in a request. This happens e. g. in test
        # cases.
        try:
            request = get_request()
        except AttributeError:
            pass
        else:
            # Users can use their own wrappers that does not necessarilly have
            # an sql_queries attribute. We create our own here, if this happens.
            request.sql_queries.append((statement, parameters, time))
예제 #4
0
def get_redirect_target(invalid_targets=(), request=None):
    """Check the request and get the redirect target if possible.
    If not this function returns just `None`.
    """
    if request is None:
        request = get_request()
    check_target = request.values.get('_redirect_target') or \
                   request.args.get('next') or \
                   request.environ.get('HTTP_REFERER')

    print check_target

    # if there is no information in either the form data
    # or the wsgi environment about a jump target we have
    # to use the target url
    if not check_target:
        return


    return check_target
예제 #5
0
파일: auth.py 프로젝트: passy/rdreilib
 def __init__(self):
     self.environ = get_request().environ