Directly use objects in classifying folder portlet #50783

This commit is contained in:
Nicolas Demonte 2021-02-11 15:12:37 +01:00
parent f47560ca3e
commit 36f13e5561
1 changed files with 5 additions and 10 deletions

View File

@ -113,7 +113,7 @@ class Folder(Container):
l.extend(parent.parent_folders_intid_tree(limit=limit-1)) l.extend(parent.parent_folders_intid_tree(limit=limit-1))
return l return l
def child_folders_brains(self): def child_folders_objects(self):
from .link import ILink from .link import ILink
intids = component.getUtility(IIntIds) intids = component.getUtility(IIntIds)
intid_catalog = component.getUtility(ICatalog) intid_catalog = component.getUtility(ICatalog)
@ -122,8 +122,7 @@ class Folder(Container):
except KeyError: except KeyError:
return [] return []
children = [] folders = []
uuids = []
sm = getSecurityManager() sm = getSecurityManager()
for item in intid_catalog.findRelations({ for item in intid_catalog.findRelations({
'to_id': intid, 'to_id': intid,
@ -137,16 +136,12 @@ class Folder(Container):
document = aq_parent(link) document = aq_parent(link)
if IFolder.providedBy(document): if IFolder.providedBy(document):
uuids.append(IUUID(document)) folders.append(document)
portal_catalog = api.portal.get_tool('portal_catalog') return sorted(folders, key=lambda x: x.Title().lower().strip())
return portal_catalog.searchResults({'UID': uuids}, sort_on='sortable_title')
def child_folders(self): def child_folders(self):
return [IContentListingObject(x) for x in self.child_folders_brains()] return [IContentListingObject(x) for x in self.child_folders_objects()]
def child_folders_objects(self):
return [x.getObject() for x in self.child_folders_brains()]
def intid(self): def intid(self):
intids = component.getUtility(IIntIds) intids = component.getUtility(IIntIds)