from quixote import get_session, get_request, redirect

from qommon.errors import *

class AccessUnauthorizedError(AccessError):
    def render [html] (self):
        session = get_session()
        request = get_request()
        query = request.get_query()
        session.after_url = request.get_url()
        if query:
            session.after_url += '?' + query
            session.after_url = str(session.after_url)
        login_url = '%s/liberty/larpe/login' % request.environ['SCRIPT_NAME']
        redirect(login_url)
