Seen on Plone 4.3.18 with plone.api 1.8.4, but I don't see anything in later releases that would fix this.
As example, you have three folders and two documents with the same id:
- folder1/doc
- folder2/doc
- folder3
You move both documents to the third folder:
api.content.move(source=folder1.doc, target=folder3)
api.content.move(source=folder2.doc, target=folder3)
The second call moves folder2/doc to folder3/copy_of_doc, but it returns folder3/doc, which is the original folder1/doc.
In other words: the move works, but you get the wrong object back.
This is with the default safe_id=False, so I thought this would raise an error. The documentation says about this keyword argument: "When False, the given id will be enforced. If the id is conflicting with another object in the target container, raise a InvalidParameterError. When True, choose a new, non-conflicting id."
The problem is that this safe_id parameter is only checked if you pass an explicit id parameter. I think it should also be used without this id.
So in the above case:
api.content.move(source=folder2.doc, target=folder3, safe_id=False): fail with InvalidParameterError, because another item with id doc already exists in the target.
api.content.move(source=folder2.doc, target=folder3, safe_id=True): rename the item to copy_of_doc (the OFS package does that for us), and return this item.
Does that sound good?
Seen on Plone 4.3.18 with plone.api 1.8.4, but I don't see anything in later releases that would fix this.
As example, you have three folders and two documents with the same id:
You move both documents to the third folder:
api.content.move(source=folder1.doc, target=folder3)api.content.move(source=folder2.doc, target=folder3)The second call moves
folder2/doctofolder3/copy_of_doc, but it returnsfolder3/doc, which is the originalfolder1/doc.In other words: the move works, but you get the wrong object back.
This is with the default
safe_id=False, so I thought this would raise an error. The documentation says about this keyword argument: "When False, the given id will be enforced. If the id is conflicting with another object in the target container, raise a InvalidParameterError. When True, choose a new, non-conflicting id."The problem is that this
safe_idparameter is only checked if you pass an explicitidparameter. I think it should also be used without this id.So in the above case:
api.content.move(source=folder2.doc, target=folder3, safe_id=False): fail withInvalidParameterError, because another item with iddocalready exists in the target.api.content.move(source=folder2.doc, target=folder3, safe_id=True): rename the item tocopy_of_doc(theOFSpackage does that for us), and return this item.Does that sound good?