def add_query_pregen(request, elements, kwargs):
    query = kwargs.setdefault('_query', {})
query.setdefault('foo', 'bar')
return elements, kwargs

def add_route_with_query(*args, **kwargs):
    kwargs['pregenerator'] = add_query_pregen
config.add_route(*args, **kwargs)
add_route_with_query('login', '/login')
add_route_with_query('logout', '/logout')
Pyramid: extend query string for every URL constructed by route_url