-
Notifications
You must be signed in to change notification settings - Fork 124
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
Comments
I agree, and it’s something that I’m currently going to be working on in
the next few weeks. I feel like it can be accomplished with a custom
fixture that either gets auto injected or something else, or we could
follow bottle’s format and have an @action.error decorator as well for a
function.
The major issue I see is that it bottle.error as you said is global to
py4web rather than app by app, so there must be a way to deal with that.
I’m not sure if Massimo has a better idea but I’ll try this and RFC it
later in the month after my finals.
~Andrew
…On Thu, May 27, 2021 at 3:11 PM rafucisneros ***@***.***> wrote:
I'm trying to customize the errors page for my application.
I managed to customize 404 using ***@***.***(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 <https://github.com/valq7711> this is not possible
at the moment.
https://github.com/web2py/py4web/blob/8512b5e0c7168131552477abfcf476c1f871c498/py4web/core.py#L806
I think while adding this feature would be good to also add a solution for
404, so we avoid using bottle for that.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#545>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEB27MACETM23VYFYGCYUNLTP27S3ANCNFSM45VGI2DQ>
.
|
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. 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. |
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? |
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. |
Wasn't this solved by the move to ombott? |
No, ombott only allows customization of 404/405 errors, i.e. routing errors |
This was done long ago from py4web import ERROR_PAGES This cannot be done per app so make sure only one app changes it. |
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.
py4web/py4web/core.py
Line 806 in 8512b5e
I think while adding this feature would be good to also add a solution for 404, so we avoid using bottle for that.
The text was updated successfully, but these errors were encountered: