Reputation: 3912
i would like to make a view, which lists objects in specific folder (say root/Members/myname). How to do this? I dont know how to reffer to folder. Something like:
items = []
folder = getFolder('/Members/' + myname)
for i in folder:
if isinstance(news, i):
items.append(i.title)
Hm?
Upvotes: 1
Views: 901
Reputation: 1121266
You can ask the catalog to list the contents of a given folder, by using the path index, with a depth limit:
from Products.CMFCore.utils import getToolByName
catalog = getToolByName(context, 'portal_catalog')
contents = catalog(path=dict(query='/root/Members/' + myname, depth=1))
See quering the catalog for more information.
Alternatively, you could traverse to the folder in question and call the getFolderContents
skin method on that:
memberFolder = context.unrestrictedTraverse('/root/Members/' + myname)
contents = memberFolder.getFolderContents()
The latter does the catalog search for you.
Upvotes: 3
Reputation: 4496
You can do it like this:
items = [obj.Title
for id,obj in context['test-folder'].items()
if isinstance(news, obj)]
Upvotes: 0