How can I iterate over content in a portal in exactly the order it appears to Users?
portal_catalog(sort_on=["path", "getObjPositionInParent"]) does not help because getObjPositionInParent is never used because the id of the object is in the path.
The only ideas I have right now:
Add a custom index parent_path and do portal_catalog(sort_on=["parent_path", "getObjPositionInParent"]).
Instead of doing one query do a query for each container somehow using the index is_folderish and path:
If you need to process the complete content, walk it (not using the catalog at all).
Otherwise, locate the content via a catalog search and perform the sorting externally (based on parent_path and getObjPositionInParent).
instead of passing indexObject, you can pass the function to export the content or get the object position and use the position while creating the content or whatever.
A new index with parent_path and getObjPositionInParent wouldn't solve it.
But a path index of positions in parents would. like /00001/00023/00024.
I think the reason we don't have this and walk the tree is that waking up all parents when you want a list of all content seems a reasonable performance hit?