-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
[18.0][MIG] fastapi: Migration to 18.0 #471
base: 18.0
Are you sure you want to change the base?
Conversation
…pi service excution
* add default empty method to use as dependency to get the authenticated partner * improves the demo app to illustrate the way the dependency overrides mechanism can be used to provide the right implementation to use to retrieve the authenticated partner according to the security method configured on the app * add tests for the demo app to show how the TestClient class and the dependey overrides functianality should be used to easily write tests
This method can be used to get access to the fastapi.endpoint record into your router's methods
ensure transation is rolled back in case of error and allows override / extension of the error handling globally or by app
…thin fastapi apps
Co-authored-by: Fernando <[email protected]>
…ted processing lang
A ribbon and a button are dislayed on the form view when a record needs to be synchronized. In the tree view the records to synchronize are displayed with the text decoration defined for warning. A button is also displayed on the line if sync is required and an server actions allows you to sync selected records in one click
In the same time, applies the security guidelines for the demo app
This change is a complete rewrite of the way the transactions are managed when integrating a fastapi application into Odoo. In the previous implementation, specifics error handlers were put in place to catch exception occurring in the handling of requests made to a fastapi application and to rollback the transaction in case of error. This was done by registering specifics error handlers methods to the fastapi application using the 'add_exception_handler' method of the fastapi application. In this implementation, the transaction was rolled back in the error handler method. This approach was not working as expected for several reasons: - The handling of the error at the fastapi level prevented the retry mechanism to be triggered in case of a DB concurrency error. This is because the error was catch at the fastapi level and never bubbled up to the early stage of the processing of the request where the retry mechanism is implemented. - The cleanup of the environment and the registry was not properly done in case of error. In the **'odoo.service.model.retrying'** method, you can see that the cleanup process is different in case of error raised by the database and in case of error raised by the application. This change fix these issues by ensuring that errors are no more catch at the fastapi level and bubble up the fastapi processing stack through the event loop required to transform WSGI to ASGI. As result the transactional nature of the requests to the fastapi applications is now properly managed by the Odoo framework.
…ith body content. In case of retry we must ensure that the stream pass to the Fastapi application is reset to the beginning to be sure it can be consumed again. Unfortunately , the stream object from the werkzeug request is not always seekable. In such a case, we wrap the stream into a new SeekableStream object that it become possible to reset the stream at the begining without having to read the stream first into memory.
These minimal versions ensure that the retrying mechanism from odoo is working fine with the way the werkezeug request is pass from odoo to the fastapi app.
The use of a BytesIO in place of our specialized SeekableStream class to keep the input stream in case we need to process the request again due to a retryable error outperforms both in terms of speed and memory consumption. see OCA#440 (comment) for more info.
…in paging function
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: rest-framework-17.0/rest-framework-17.0-fastapi Translate-URL: https://translation.odoo-community.org/projects/rest-framework-17-0/rest-framework-17-0-fastapi/
Currently translated at 100.0% (42 of 42 strings) Translation: rest-framework-17.0/rest-framework-17.0-fastapi Translate-URL: https://translation.odoo-community.org/projects/rest-framework-17-0/rest-framework-17-0-fastapi/it/
…e_server_exceptions=False
9ebb24f
to
a86e2a4
Compare
Hi @cormaza, thanks for the work. Do you have any idea on how to fix the tests? |
I'm not pretty sure, because if you can see test log, It seems every test works fine, but because log has an error text can't be processed as passed by CI, I think can be the parser version now aggregate another validation, maybe in older versions doesn't matter, We can ask to @pedrobaeza? WDYT? |
I don't know about this repository. @lmignon may say. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (Code + Functional review)
3d12799
to
56ede08
Compare
@lmignon I added in other test method, and now works, thank you for help |
56ede08
to
d960109
Compare
Change serialization error class to test retry failure
Depends on: