Skip to content

[IMP] snippets: preserve same file module #295

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cawo-odoo
Copy link
Contributor

@cawo-odoo cawo-odoo commented Jul 9, 2025

In make_pickleable_callback, when creating a name for the module created via import_script, no longer make the name random, but derive it from the script's path deterministically via a hash function. This way, when this method is called multiple times from the same script for multiple callbacks, it will only import the script once and otherwise re-use the created module. This ensures multiple callbacks from the same script file will run within the same module, seeing e.g. the same values in modified globals, which is much more intuitive.

Also, move the function to misc.py. With the intention to reuse it, it's a better fit. For that, make it python2 compatible.

@robodoo
Copy link
Contributor

robodoo commented Jul 9, 2025

Pull request status dashboard

@cawo-odoo cawo-odoo force-pushed the master-imp_make_pickleable_callback_preserve_same_file-cawo branch 2 times, most recently from 55085dc to 1e7abe7 Compare July 11, 2025 06:56
@cawo-odoo cawo-odoo requested review from a team and asno-odoo July 11, 2025 07:56
@cawo-odoo cawo-odoo marked this pull request as ready for review July 11, 2025 07:56
@cawo-odoo cawo-odoo requested a review from aj-fuentes July 11, 2025 09:40
@aj-fuentes
Copy link
Contributor

If we intend to reuse this in other scripts I'd move it to misc.py instead of keeping it in snippets.py (cc: @KangOl)

@cawo-odoo cawo-odoo force-pushed the master-imp_make_pickleable_callback_preserve_same_file-cawo branch 2 times, most recently from cc1dcba to 214126f Compare July 11, 2025 13:29
@cawo-odoo cawo-odoo force-pushed the master-imp_make_pickleable_callback_preserve_same_file-cawo branch 2 times, most recently from 874c7e4 to 5c41b91 Compare July 11, 2025 13:44
In `make_pickleable_callback`, when creating a name for the module created via
import_script, no longer make the name random, but derive it from the script's
path deterministically via a hash function. This way, when this method is
called multiple times from the same script for multiple callbacks, it will only
import the script once and otherwise re-use the created module. This ensures
multiple callbacks from the same script file will run within the same module,
seeing e.g. the same values in modified globals, which is much more intuitive.

Also, move the function to `misc.py`. With the intention to reuse it, it's a
better fit. For that, make it python2 compatible.
@cawo-odoo cawo-odoo force-pushed the master-imp_make_pickleable_callback_preserve_same_file-cawo branch from 5c41b91 to 3d69959 Compare July 11, 2025 14:21
@KangOl
Copy link
Contributor

KangOl commented Jul 11, 2025

upgradeci retry with always only website documents mrp spreadsheet_editions

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.

4 participants