def default_login_variables(request):
    """Returns a dict with login variables that should be shared between the
    GET and the POST (i.e. failed login) versions of the page.
    """
    referrer = request.url

    came_from = request.params.get('came-from', referrer)
    login_url = request.route_url('log-in')
    if came_from == login_url:
        # Never use the login form itself as came_from
        came_from = request.route_url('home')

    login = request.params.get('login', '')

    return {
        'post_url': request.route_url('log-in-post'),
        'came_from': came_from,
        'login': login,
    }