import quixote
from quixote.errors import *

import template

class AccessUnauthorizedError(AccessError):
    def render [html] (self):
        session = quixote.get_session()
        request = quixote.get_request()
        session.after_url = request.get_url()
        login_url = '/liberty/larpe/login'
        quixote.redirect(login_url)

class AccessForbiddenError(AccessError):
    def render [html] (self):
        return template.error_page(_('Access Forbidden'))

class EmailError(Exception):
    pass

TraversalError.title = N_('Page not found')
TraversalError.description = N_(
    "The requested link does not exist on this site.  If "
    "you arrived here by following a link from an external "
    "page, please inform that page's maintainer.")


def format_publish_error [html] (exc):
    return template.error_page(_(exc.description), _(exc.title))

