Retrieve objects in folders

To retrieve the objects (just a few images, in average less than 6) in folders, what is the best/recommended approach:

  1. items() (does not look at the catalog??)
  2. getFolderContents() (looks at the catalog, so maybe more overhead?)

If it's just a few images and you're going to need to load the full image objects anyway to render your page, I would definitely use items() (or values()) rather than a catalog query.

Given you have all Dexterity:
If its just a few and no other content objects are in the folder: use direct iteration on the containing folder.
if there are "more" (say >50-100) other objects to wake up in order to get the six use the catalog, maybe together with the generic functionality of

Just be aware that you're not filtering on security with direct iteration.

Thanks for your answers.
I will go for items() (or values()).

When you say security, you mean permissions, right?

@JotaMG I just fixed a bug in a project where using direct iteration raised UnAuthorized errors. The fix for that was to avoid iteration and do a catalog query on the path of the parent. The upside of the catalog query is, that it filters on 'allowed roles and users', so it results in a list that takes into account the permissions of the user requesting the listing view.

you can use listFolderContents which is aware of filtering and security; see:

I think it works also on Dexterity-based containers.

1 Like

Yes, it works, and if there are no more sugestions it will go into my addon, and I will close the case :wink:
Many thanks to you all for the help!