f61aa39ff1190f66cebb8efb8432723214932161
This commit is the 9th commit of a comprehensive refactor of our HTTP framework. See odoo/odoo#78857 for complete historic, discussions and rationnals. See also [REF] core: HTTPocalypse (11) ir.http base model. This is a two-part commit with "(11) ir.http base model". In this commit we focus on the initialization of the various ORM objects, namely: the registry, the cursor, the environment, the user and the context. In the other n°11 commit we focus on the ir.http model and its relation to the current http.py module. One of the objectives of this comprehensive refactor was to ease the cognitive complexity of the http framework, in other words to make it simplier. One of the problem identified quite early during the preparation of this work is the way the various ORM objects are initialized, modified and cleaned during the request lifetime. Before this work, all the ORM internals were lazily initialized via properties. It is the first time one uses `request.cr` that a cursor is opened to `request.db` and stored on `request._cr`. It is the first time one uses `request.env` that an environment is create with the current `request.user` and `request.context`. Upon user or context modification, the current environment is discarded, the next usage of `request.env` will create yet another environment on the fly using the modified user and/or context. Using this model, no ressource is initialized if not necessary. It is possible for nodb-compatible endpoint to be served via the db-compatible router and ir.http without ever opening a cursor to the database. But this model is harder to reason about and ultimately to maintain. In this work we propose to drop the lazy approach for a greedy one. In this work the first steps of `_serve_db`, the db-compatible counter-part of `_serve_nodb`, are dedicated to setup a registry, open a cursor to the database and create an environment using the session's user and context. In this work, when one wants to change the environ's user or context, he must call `request.update_env` or `request.update_context`, both method will recreate the environment *now* with the given values. The downside of this approach is that resources are always allocated even when it is not necessary. We argue that, in general, the controllers that do not use the ORM are rare thus it is rare we allocate unecessary resources. We also argue that the cognitive benefits are more than welcome and that the new APIs will help at writing more robust applications. PR: odoo#78857 Task: 2571224
Odoo
Odoo is a suite of web based open source business apps.
The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...
Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
Getting started with Odoo
For a standard installation please follow the Setup instructions from the documentation.
To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials
Languages
Python
49.6%
JavaScript
47.8%
SCSS
2%
CSS
0.3%
HTML
0.2%