Browse Source

Cleans up the files from debugging

merge-requests/141/head
NubWizard 2 years ago
committed by Bauke
parent
commit
d49c69da10
  1. 7
      tildes/tildes/routes.py
  2. 15
      tildes/tildes/views/exceptions.py

7
tildes/tildes/routes.py

@ -191,7 +191,12 @@ def add_intercooler_routes(config: Configurator) -> None:
class LoggedInFactory:
"""Simple class to use as `factory` to restrict routes to logged-in users."""
"""Simple class to use as `factory` to restrict routes to logged-in users.
This class can be used when a route should only be accessible to logged-in users but
doesn't already have another factory that would handle that by checking access to a
specific resource (such as a topic or message).
"""
__acl__ = [
(Allow, Authenticated, "view"),

15
tildes/tildes/views/exceptions.py

@ -83,11 +83,10 @@ def generic_error_page(request: Request) -> dict:
request.response.status_int = request.exception.status_int
error = f"Error {request.exception.status_code} ({request.exception.title})"
description = ""
if isinstance(request.exception, HTTPForbidden):
description = request.exception
elif isinstance(request.exception, HTTPUnprocessableEntity) and isinstance(
description = "You don't have access to this page"
if isinstance(request.exception, HTTPUnprocessableEntity) and isinstance(
request.exception.__context__, ValidationError
):
errors = errors_from_validationerror(request.exception.__context__)
@ -95,14 +94,7 @@ def generic_error_page(request: Request) -> dict:
else:
description = request.exception.explanation
# For debugging, add the exception details
debug_info = {
"message": str(request.exception),
"type": str(type(request.exception)),
"args": request.exception.args,
}
return {"error": error, "description": description, "debug_info": debug_info}
return {"error": error, "description": description}
@forbidden_view_config(xhr=False)
@ -112,3 +104,4 @@ def logged_out_forbidden(request: Request) -> HTTPFound:
login_url = request.route_url("login", _query={"from_url": forbidden_path})
return HTTPFound(location=login_url)
Loading…
Cancel
Save