Listing.pt calls getObject for every item

OOTB in Plone 6 listing.pt and FolderView in plone.app.contenttypes both call getObject() method of catalog brains for every listing item, which seems suboptimal.

This seems to evaluate whether content provides IEvent — I feel like there must be a more efficient way to do this, some notion of duck typed detection of event (from stuff now or ideally stored in metadata columns) so there's not a getObject() for every single item in the listing?

As it is, I do not see a metadata column that makes this detection for an item easy (IIRC, portal_type alone is not sufficient here). Routing around that, it might be possible to have FolderView perform an additional query against the object_provides index to load a list of UUIDs for items providing IEvent, like:

self._event_uids = [
    brain.UID for brain in
    catalog.unrestrictedSearchResults(object_provides=IEvent.__identifier__)
]

...with assumption that FolderView.is_event() and usage in listing templates are adjusted accordingly to only deal with brains without traversal to content — except when object appears to be an event.

The current situation seems sub-optimal (mostly for larger batch size display): special-case support for plone.app.event when most folder listings don't need this.

1 Like