Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors Page Customization #545

Open
rafucisneros opened this issue May 27, 2021 · 7 comments
Open

Errors Page Customization #545

rafucisneros opened this issue May 27, 2021 · 7 comments

Comments

@rafucisneros
Copy link

I'm trying to customize the errors page for my application.
I managed to customize 404 using "@bottle.error(404)" (although I think it changes the error page for every app) and 403 using a custom fixture to check user roles, but I can't figure a way to customize error 500.

According to @valq7711 this is not possible at the moment.

raise bottle.HTTPResponse(

I think while adding this feature would be good to also add a solution for 404, so we avoid using bottle for that.

@agavgavi
Copy link
Contributor

agavgavi commented Jun 3, 2021 via email

@mdipierro
Copy link
Contributor

There are two problems . One problem is that some error pages (for example 404) cannot be application specific because which app is not defining the missing page. So who's responsibility is it to define the error page.
Another problem is how to the case or an error in a custom error page.

One option is to create 404.html, 500.html, etc in template/errors/ and, if py4web knows which app to look into and find them, use them, else revert to current behavior. This would be easy.

@KellerKev
Copy link
Collaborator

An error app in the app folders with those templates seems cool to me. Would also make editing those templates a snap. There could be a scaffolding error app and the error app can be defined and customized per any other app that need to use it?

@KellerKev
Copy link
Collaborator

The issue is that we do our own app management instead of using a bottle instance per app. We are using one botte instance for all apps as far as I understand, hence we have the problem that all our error messages are global. Workaround is probably to save a list of apps and the stuff they need for custom error messages like links, texts, template paths for different errors in a config file such as json or yaml or even csv or the db and when py4web checks what app name is currently being used for the global error message in core.py it should check in that config file or db if this app with that app name that throws the error has a custom error html template and other related content that is supposed to be used. I commented on that in the mailing list in more detail.

@mdipierro
Copy link
Contributor

Wasn't this solved by the move to ombott?

@valq7711
Copy link
Collaborator

Wasn't this solved by the move to ombott?

No, ombott only allows customization of 404/405 errors, i.e. routing errors

@mdipierro
Copy link
Contributor

This was done long ago

from py4web import ERROR_PAGES
ERROR_PAGES["404"] = "Doh! 404"

This cannot be done per app so make sure only one app changes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants