Previous documentation referenced a non-existent property on the Flask
object called "build_error_handler".
This should actually reference Flask.url_build_error_handlers.
This allows adding error handlers like this:
@app.errorhandler(werkzeug.exceptions.Forbidden)
And subclassing HTTPExceptions:
class ForbiddenBecauseReason(Forbidden): pass
@app.errorhandler(ForbiddenBecauseReason)
def error1(): return "Forbidden because reason", 403
@app.errorhandler(403)
def error2(): return "Forbidden", 403
... the idea being, that a flask extension might want to raise an
exception, with the default behaviour of creating a HTTP error page,
but still allowing the user to add a view/handler specific to that
exception (e.g., "Forbidden because you are not in the right group").
The main application object has a register_error_handler function
which mirrors the decorator's functionality. According to the principle
of least surprise, make sure blueprints also have this convenience function.
When a PEP 302 import hook is used that doesn't implement .is_package()
an AttributeError is raised. This looks like a bug in Flask. This change
fixes that problem in the sense that it explains, that the
AttributeError is intentional.
Tests when simplejson was installed were failing because of a change in
how it sorted in v3.0.0. This change first tests it via normal int
sorting for stdlib json then if that fails, it tests against str sorting
for simplejson.
This also changes how sessions are being refreshed. With the new
behavior set-cookie is only emitted if the session is modified or if the
session is permanent. Permanent sessions can be set to not refresh
automatically through the SESSION_REFRESH_EACH_REQUEST config key.
This fixes#798.