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