An Ordered BTreeFolder
by
hedley
—
posted on
Apr 04, 2008 12:48 PM
—
last modified
Apr 04, 2008 12:48 PM
BTreeFolders are lightweight, but wouldn't it be nice to order the items as you see fit?
A while ago I needed to store items in a BTree Folder (an instance of BTreeFolder2), but I needed to set a custom ordering of items. The normal BTreeFolder2 has no concept of order - it simply returns items in the order that they were added to the folder.
So why not use OrderedBaseFolder from Archetypes? Well, this was a non-Archetypes project, and OrderedBaseFolder is a bit too heavy for this use case.
My solution was to subclass BTreeFolder2 into OrderedBTreeFolder2 and override certain methods. The API is backwards compatible with BTreeFolder2.






