You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
👍 that is a thing which is also annoying me.
I also almost always pass the id to avoid the object to be moved after creation.
But I fear that in some cases this can be hard.
The auto generated id might be based:
the title (e.g. pages or folders)
file
image
whatever your custom logic wants
Now the object is created using container.invokeFactory(type, content_id, **kwargs).
The parameter content_id is either the id which is passed by the user or a generated one.
I bet some lower level method that does not attach the object to the container could be used.
Anyway if you could make a PR to fix this I will be super happy to review it.
If we do not manage to fix this, we should document what is happening very precisely.
IIRC this is not the first time this topic is dicussed.
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: