Closed mauritsvanrees closed 3 years ago
A quick pdb session:
[49] > /Users/maurits/community/plone-coredev/py3/src/plone.folder/src/plone/folder/default.py(160)getObjectPosition()
-> raise ValueError('No object with id "{0:s}" exists in "{1:s}".'.format(
(Pdb++) l
155 pos = self._pos()
156 if obj_id in pos:
157 return pos[obj_id]
158 import pdb; pdb.set_trace()
159
160 -> raise ValueError('No object with id "{0:s}" exists in "{1:s}".'.format(
161 obj_id, '/'.join(self.context.getPhysicalPath())))
162
163 def idsInOrder(self):
164 """ see interfaces.py """
165 return list(self._order())
(Pdb++) self._pos()
<BTrees.OIBTree.OIBTree object at 0x11847e440 oid 0x38a8 in <Connection at 115187b50>>
(Pdb++) list(self._pos())
['link-2']
(Pdb++) self.context.objectIds()
['pagina-1', 'link-1', 'link-2']
The list of object ids is what I expect. The _pos
(ordering) only contains the new link object I added. So the ordering seems to get overwritten on check-in.
I do remove the annotation on check-in: https://github.com/plone/plone.app.iterate/blob/656957d439f53d9d6f05668b964fe670a71cbaac/plone/app/iterate/dexterity/copier.py#L256 it seems that I missed to remove the pos one, but (right now testing it) and it breaks also...
No, it doesn't work either...
Breaks even without copying any annotation??? I don't get it...
well... ONLY moving the objects programatically causes that.
@mauritsvanrees @jensens I am missing something?
Before cutting those objects, I get this:
(Pdb++) IAnnotations(self.context)["plone.folder.ordered.order"]
['link-2']
(Pdb++) IAnnotations(self.context)["plone.folder.ordered.pos"]
<BTrees.OIBTree.OIBTree object at 0x10dc5de40 oid 0x3c08 in <Connection at 10d8bd280>>
(Pdb++) list(IAnnotations(self.context)["plone.folder.ordered.pos"])
['link-1', 'link-2', 'page-1']
So the working copy has more items in pos
than in order
.
After pasting, it becomes this:
(Pdb++) list(IAnnotations(self.context)["plone.folder.ordered.pos"])
['link-2']
(Pdb++) IAnnotations(self.context)["plone.folder.ordered.order"]
[]
So order
is empty then, but pos
still has content. A bit surprising, but I guess the plone.folder
code gets confused when the two are not in sync.
I don't really know why we have two of these annotations that seem very similar...
I thought this would help, but it does not:
if "plone.folder.ordered.order" in wc_annotations:
wc_annotations.pop("plone.folder.ordered.order")
if "plone.folder.ordered.pos" in wc_annotations:
wc_annotations.pop("plone.folder.ordered.pos")
Maybe it helps if we do not set the pos
annotation when creating the initial check-out? We only remove the order now, not the pos.
That seems to help. Then pos
and order
only contain the new object id before cutting. And after pasting, both are empty.
So: in all places where we pop the order
annotation, we should pop the pos
annotation.
Can you try that?
I will!
@mauritsvanrees works! Phew! Thanks for the help! I will push a fix!
Copied from this PR comment:
I tried it just now in Plone 5.2 Python 3 with your code. I do see a problem.
Traceback
A clear and rebuild of the catalog does not help.