Non-structural folders
RichDocument has to be containerish so that it can contain files and attachments. Thus, it extends OrderedBaseFolder. However, to the user, a document is not a folder.
Folders in Plone 2.1 get a few particular UI features:
- A
contentstab (unlike in Plone 2.0, there is nocontentstab on non-folders in Plone 2.1, because with the newactionsmenu, there is much less need to use this view) - An
add itemmenu to add items to the folder instead of anadd to foldermenu to add sibling items in the parent folder. - If you are in a parent folder's
contentstab and click a folder, you will see that folder'scontentstab, too.
Plone checks whether an item is a folder using the is_folderish script. The expression object/is_folderish (and its catalog metadata equivalent, which for efficiency reasons is implemented using ExtensibleObjectIndexWrapper in CMFPlone/CatalogTool.py) will evaluate to True if object is a "structural folder" – that is, if it is a folder in the UI sense.
By default, all folders are structural, unless they implement the INonStructuralFolder marker interface defined in CMFPlone/interfaces/NonStructuralFolder.py. RichDocument does just this:
__implements__ = ATDocument.__implements__ + (IRichDocument, INonStructuralFolder,)
And as if by magic, the folder acts like a folder no more.
Finally, because being able to choose a contained item as a default-view does not make sense for RichDocument, we use the method canSetDefaultView from ISelectableBrowserDefault (see the section on dynamic views) to explicitly disallow default views:
def canSetDefaultPage(self):
return False