Beispiel #1
0
def notfound_get(request):
    _ = request.translate
    title = _("Error 404")
    body = _("Sorry, the requested ressource could not be found!")
    renderer = ErrorDialogRenderer(request, title=title, body=body)
    rvalue = {}
    rvalue['dialog'] = renderer.render()
    request.response.status = 404
    return rvalue
Beispiel #2
0
def forbidden(request):
    _ = request.translate
    title = _("Error 403")
    body = _("Authorisation error! Sorry, you are not allowed"
             " to access to requested ressource!")
    renderer = ErrorDialogRenderer(request, title=title, body=body)
    rvalue = {}
    rvalue['dialog'] = renderer.render()
    request.response.status = 403
    return rvalue
Beispiel #3
0
def import_(request, callback=None):
    clazz = request.context.__model__
    _ = request.translate
    renderer = ImportDialogRenderer(request, clazz)
    imported_items = []
    form = renderer.form
    if (request.method == 'POST' and request.ringo.params.confirmed
            and form.validate(request.params)):
        try:
            items = _import(request)
        except (ValueError, AttributeError) as e:
            err_title = _("Import failed")
            err_msg = _(
                "Bad news! The import could not be finished and "
                "returns with an error."
                "No data has been modified in this operation and no "
                "items has been imported or updated. "
                "The last message we heard from the importer was: %s") % e
            renderer = ErrorDialogRenderer(request, err_title, err_msg)
            rvalue = {}
            ok_url = request.ringo.history.pop(2)
            rvalue['dialog'] = renderer.render(ok_url)
            rvalue['clazz'] = clazz
            return rvalue

        imported_items = _handle_save(request, items, callback)
        invalidate_cache()
        redirect = _handle_redirect(request)
        if redirect:
            return redirect
    rvalue = {}
    rvalue['dialog'] = renderer.render(imported_items)
    rvalue['clazz'] = clazz
    return rvalue