-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
In api.content.create, avoid renaming object if "id" was not given #439
Comments
👍 that is a thing which is also annoying me. But I fear that in some cases this can be hard. The auto generated id might be based:
Now the object is created using Anyway if you could make a PR to fix this I will be super happy to review it. IIRC this is not the first time this topic is dicussed. |
+1000 |
Is this issue resolved if not I would like to work on this as in create its logic is if not id or (safe_id and id) which bascially works even if there is no id where as it should check if id not present than it should create a temp id and do. |
@abhishekdubey369 You haven't understood the issue. There is already a temporary id created. The point of the issue is to avoid doing that by generating the final id. But this is quite complicated to do correctly in every case, and sometimes impossible. |
hello @davisagli , chooser = INameChooser(container) if not id: if title:
return container[content_id] what mess can it create ? |
@abhishekdubey369 The next step needed here is a careful review of @ale-rt's existing PR, not a new implementation. |
existing PR is #484 |
Hi @jensens @ale-rt
we discovered that when creating an element using content.create without specifying an "id", it was created then renamed, this cause ContainerModified event to be called 2 times (and some other events too).
I wondered why this was done in 2 steps? Could it be done before creating the element?
https://github.com/plone/plone.api/blob/master/src/plone/api/content.py#L118
Actually the element is created and if id is not given, then it is renamed to a computed id.
I think we could check if "id" is given, then generate it and pass it to invokeFactory instead renaming it after?
Or is there some reason why it is done after?
We could propose a PR "solving" this.
We avoid this by passing a generated id to content.create now.
Thank you,
Gauthier
The text was updated successfully, but these errors were encountered: