📝 Remove references to `#app.on_event` in the SQL database section
Overview
This pull request updates the FastAPI documentation to reflect the deprecation of the @app.on_event decorator in the SQL database section of tutorial. The documentation has been revised to guide users towards using the new lifespan event handling system for managing application startup and shutdown events.
Changes Made
Updated Documentation:
- Removed references to @app.on_event in python
doc_srcfiles. - Code demonstration updated in documentation markdown files for English.
Testing
- Reviewed all modified documentation for accuracy and clarity.
- Ensured that all examples are functional and correctly illustrate the new usage patterns.
📝 Docs preview for commit 684048376202f1af5f38c34437a7a7efdb94a90b at: https://af29a5e2.fastapitiangolo.pages.dev
Modified Pages
- https://af29a5e2.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
📝 Docs preview for commit d74bee7fe2eb006f183a5bc28357077d4a87d3c1 at: https://2fd15ee3.fastapitiangolo.pages.dev
Modified Pages
- https://2fd15ee3.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
I support the changes proposed by @IdleSys. :+1:
The corrections I suggested are optional, and it is up to the PR author to implement them or not. :blush:
📝 Docs preview for commit 3afe5457823f9db609b455565c120b4c799d51d6 at: https://95e4f9b5.fastapitiangolo.pages.dev
Modified Pages
- https://95e4f9b5.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
📝 Docs preview for commit 2f95f2b8fdd1d5391c3b15362bd301aaefc67f13 at: https://427ce36a.fastapitiangolo.pages.dev
Modified Pages
- https://427ce36a.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
There is one more thing to think about: when the reference code is modified all the translations related to it will get corrupted.
Thank you for your input, @alv2017
Currently, I am facing an issue where my local preview does not match the preview of the link that robot provided. Regarding the problem you mentioned, it arises from my changes to the document sources. I see two possible solutions:
- Separate the sources until the translations are updated to align with the new source. This approach would also retain the deprecated statements for translations.
- Sync the translations with the new source, although I doubt my time and interest will allow me to pursue this option.
-
I reviewed updated code references, everything looks good now.
-
In the mean time I found out that there are not that many translations of the
sql-databases.md:
- es
- ko
- pt
- ru
- zn
all the groups are quite active, and probably it won't be difficult to get support from them
- There is an alternative solution. The source files related to the tutorials have a special structure:
If we create a file named
tutorial001_py311_an.pyand apply all the necessary changes there, and then link it to the english version of the tutorial, then translations won't be affected.
I think that we will need help from the maintainers to move forwards with that.
@alv2017 Good News
I successfully navigated through the Spanish version and updated all occurrences of old references using sed and I would appreciate it if someone from another language team could visually check and confirm the changes.
📝 Docs preview for commit 85504e62ac9f9d143899707d3c394254429371ed at: https://1ac48c4a.fastapitiangolo.pages.dev
Modified Pages
- https://1ac48c4a.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
- https://1ac48c4a.fastapitiangolo.pages.dev/es/tutorial/sql-databases/ - (before) - (English)
- https://1ac48c4a.fastapitiangolo.pages.dev/ko/tutorial/sql-databases/ - (before) - (English)
- https://1ac48c4a.fastapitiangolo.pages.dev/pt/tutorial/sql-databases/ - (before) - (English)
- https://1ac48c4a.fastapitiangolo.pages.dev/ru/tutorial/sql-databases/ - (before) - (English)
- https://1ac48c4a.fastapitiangolo.pages.dev/zh/tutorial/sql-databases/ - (before) - (English)
Hi @tiangolo, @alejsdev, sorry for bothering you, but we need your help and guidance.
We would like to make some updates to the code related to the SQL (Relational) Databases tutorial, and guide users towards using the new lifespan event handling system for managing application startup and shutdown events.
However when working on the PR we noticed, that it gets overly complex. The PR in its current state demonstrates the scope of work that needs to be done in order to introduce the change.
The required changes are as follows:
- Code updates
- English documentation update
- The update of existing translations (mainly code references): At the moment the following translations are available: es, ko, pt, ru, zh
Questions:
- Do you agree with this change in documentation?
- If yes, then we will be happy to help, but we need your guidance and advice on making the PR.
Thank you! :blush:
@IdleSys:
- Please sync your PR with the master branch.
Hi @svlandeg, please confirm that the maintenance team
- is removing/deprecating
app.on_eventfunctionality; - is OK to move forwards with this PR.
Thank you! :smiley:
@IdleSys, @svlandeg I suggest that in this PR we are changing only:
a) the source code of the tutorials b) code references in the affected tutorials without changing the content of the tutorials.
In this case we will be able to handle this PR within the current team.
If there is a need we can modify the content on the tutorial in another PR, and ask translators for help.
What do you think?
📝 Docs preview for commit 64b1d08bea17d82af1e44cc9ba8963dd86b10e2c at: https://5471282a.fastapitiangolo.pages.dev
Modified Pages
- https://5471282a.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
- https://5471282a.fastapitiangolo.pages.dev/es/tutorial/sql-databases/ - (before) - (English)
- https://5471282a.fastapitiangolo.pages.dev/ko/tutorial/sql-databases/ - (before) - (English)
- https://5471282a.fastapitiangolo.pages.dev/pt/tutorial/sql-databases/ - (before) - (English)
- https://5471282a.fastapitiangolo.pages.dev/ru/tutorial/sql-databases/ - (before) - (English)
- https://5471282a.fastapitiangolo.pages.dev/zh/tutorial/sql-databases/ - (before) - (English)
Hi @alv2017 and sorry for delay. I think the changes to the English docs i made were necessary ( I mean the tutorial itself not only the code). We needed to change the text to point out this new feature. I will be appreciated if you could take a look at it and give me a more specific list of what we should do next to make changes applicable on the project. It must be me but I have hard time understanding what you mean.
Hi @IdleSys,
My suggestions remain the same in https://github.com/fastapi/fastapi/pull/13253#issuecomment-2799968676
Let me explain why:
-
We completely removed everything related to
@app.on_eventfrom the code related to this tutorial. I see no reason to stress that this functionality has been deprecated in the SQL Model tutorial. This is something that needs to be pointed out in the lifespan and server events related tutorial. -
This warning adds additional complexity and inconsistency to the PR. The updates in English tutorial are not fully aligned with the tutorials in other languages.
📝 Docs preview for commit 4564fe648290d564cb6e443277d2c40b4410ef60 at: https://27bf135b.fastapitiangolo.pages.dev
Modified Pages
- https://27bf135b.fastapitiangolo.pages.dev/tutorial/sql-databases/ - (before)
- https://27bf135b.fastapitiangolo.pages.dev/es/tutorial/sql-databases/ - (before) - (English)
- https://27bf135b.fastapitiangolo.pages.dev/ko/tutorial/sql-databases/ - (before) - (English)
- https://27bf135b.fastapitiangolo.pages.dev/pt/tutorial/sql-databases/ - (before) - (English)
- https://27bf135b.fastapitiangolo.pages.dev/ru/tutorial/sql-databases/ - (before) - (English)
- https://27bf135b.fastapitiangolo.pages.dev/zh/tutorial/sql-databases/ - (before) - (English)
This pull request has a merge conflict that needs to be resolved.