-
Notifications
You must be signed in to change notification settings - Fork 1
Draft generic context store definition #1
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
Draft generic context store definition #1
Conversation
|
Additional context in OCA#406 (comment) |
|
Depending on the discussion on OCA#406 I think everyone want the full context by default. And set which keys should be preserved for each module is quite repetitive to implement. I'm not in favor of this PR. |
|
Hmm, I think you are mistaken.
I'm really not sure about this, firstly because it is not safe : not everything can be serialized to json and the values stored in the context are quite liberal (even python objects sometimes), we would have errors. I would not accept to store any automatically in the context.
You misread my PR. The set of keys is global.
What examples do you have where you need this? |
|
Another issue I have with OCA#406 is that if I have a job |
|
If really we would like to customize the context keys per job, IMO it should be stored in the A version I'd prefer is:
It seems to me it is simpler that OCA#406 both in term of implementation and of usage, and should cover all of your use cases. |
|
IMO, like I have said already, I really don't see why we would not want the full context to be passed in case of the job. About the context keys passed, I believe if the full context is passed, it is better because we want our method to work the same way when it is called through a job or not... But like guewen said here, it is complicated because we could have anything in the object like python object, recordset... Finally about the possibility to configure the context per job instead of per model, I don't see in which case it could be needed. I am not sure it is worth worrying about this now unless someone has a use case of this kind ? So overall I like this PR that IMO simplify things quite a lot, at least for the "standard/ordinary" case, where we always want to pass the context and we don't need to configure it per job. |
|
I've to agree with @guewen, i see this PR more straightforward and a simpler way to implement. So IMO, 👍🏻 to this one. |
I understand the 'not safe' part. That make sense. But it's easy to work with: just keep serializable keys.
Into the original PR they want the context by default. So I update my PR with that.
Yes sorry, I miss read. I think it's a good idea if we always want some keys (company etc). But anyway, I think the original PR is a good point to start and of course it should evolve. |
On the contrary and that's exactly what I try to explain : by changing the API and asking devs to add the 'keep_context' arg in their calls to Furthermore, I'm sorry but the complexity added in job.py "just" for storing the context seems a bit too much for the requirement. This is even more true if we magically sanitize the context by keeping only serializable values (not sure it is that easy and performant but this is another story). Could you explain to me the uses cases where you would need to set different parameters in your |
|
I understand you already invested a lot of time on this and probably have implementations relying on this and I ask for important changes. |
|
@acsonefho I realized that the option |
Proposal to store the context, thinking about a migration path to enable storing the context keys by default :
_job_prepare_context_before_enqueue_keysin the base model or any model to define the keys to store in the contextI didn't adapt the tests yet, this is mainly for discussion as of now.