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

[18.0][MIG] endpoint_route_handler: Migration to 18.0 #69

Open
wants to merge 53 commits into
base: 18.0
Choose a base branch
from

Conversation

cormaza
Copy link

@cormaza cormaza commented Nov 8, 2024

Supersed #65

Added parameter readonly in route definition, by default false to keep standard behavior

simahawk and others added 30 commits November 8, 2024 11:37
When an endpoint is archived it must be dropped.
When it's unarchive it must be restored.
Routing maps are generated **per env**
which means that every new env will have its own routing map
attached to `ir.http` registry class.

This is not desired (as per core Odoo comment)
but it's like this today :/

Hence, before this change, the routing map could be mis-aligned
across different envs leading to random responses for custom endpoints.

This refactoring simplifies a lot the handling of the rules
leaving to std `_generate_routing_rules` the duty to yield rules
and to `routing_map` to generate them for the new route map.

EndpointRegistry memory consumption is improved too
thanks to smaller data to store and to the usage of __slots__.
To avoid multiple invalidation of all envs on each edit or create
of persistent records, a new flag is introduced: 'registry_sync'.

This flag delays the sync of the rule registry till manual action
occurs. Records in the UI are decorated accordingly to notify users of
the need to reflect changes on ther registry to make them effective.

The sync happens in a post commit hook to ensure all values are in place
for the affected records.
Depending on your modules inheritance and upgrade order
when you introduce this mixin on an existing model
it might happen that
gets called before the model's table is ready
(eg: another odoo service loading the env before the upgrade happens).
Let if fail gracefully since the hook will be called again later.
As routes are registered automatically in the db after sync
there's no reason to look for non registered routes at boot.
Furthermore, this is causing access conflicts on the table
when multiple instances w/ multiple workers are spawned.
@cormaza cormaza force-pushed the 18.0-mig-endpoint_route_handler branch from 52c406f to 2f0075e Compare November 8, 2024 17:08
@cormaza
Copy link
Author

cormaza commented Nov 8, 2024

Thanks for this module @simahawk, please let me know if everything is fine

@simahawk
Copy link
Contributor

/ocabot migration endpoint_route_handler

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Nov 20, 2024
@OCA-git-bot OCA-git-bot mentioned this pull request Nov 20, 2024
2 tasks
@simahawk
Copy link
Contributor

simahawk commented Nov 20, 2024

Thanks for your work!
LG but I think we miss this PR that is not fwd ported yet to v17 #52
Would you mind porting it to 17 and then cherry-pick the commit here?

@cormaza
Copy link
Author

cormaza commented Nov 20, 2024

Thanks for your work! LG but I think we miss this PR that is not fwd ported yet to v17 #52 Would you mind porting it to 17 and then cherry-pick the commit here?

I'm no really sure, because in version 16 you have a class method, then in 17 version is a regular function, maybe we can include after forward ported to 17 version I can include in this MR, wdyt?

@simahawk
Copy link
Contributor

Sure, we have to port all changes to v17 first. You can try https://github.com/OCA/oca-port 😉

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

Successfully merging this pull request may close these issues.

9 participants