Commit bc44d60b authored by Julien Muchembled's avatar Julien Muchembled

Fix and reapply [29873] (rewrite Folder.contentValues for CMF 2.2 and performance)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29909 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 25926c35
......@@ -35,6 +35,7 @@ import ExtensionClass
from Products.CMFCore.utils import _getAuthenticatedUser
from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
from Products.CMFCore.PortalFolder import ContentFilter
from Products.ERP5Type.Base import Base
from Products.ERP5Type.CopySupport import CopyContainer
......@@ -1433,24 +1434,21 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
security.declareProtected( Permissions.AccessContentsInformation,
'contentValues' )
def contentValues(self, spec=None, meta_type=None, portal_type=None,
sort_on=None, sort_order=None, checked_permission=None, **kw):
def contentValues(self, *args, **kw):
# Returns a list of documents contained in this folder.
# ( no docstring to prevent publishing )
if meta_type is not None:
spec = meta_type
if portal_type is not None:
kw['portal_type'] = portal_type
filter = kw.pop('filter', {}) or {}
kw.update(filter)
if self._folder_handler == HBTREE_HANDLER:
object_list = CMFHBTreeFolder.contentValues(self, spec=spec, filter=kw)
else:
object_list = CMFBTreeFolder.contentValues(self, spec=spec, filter=kw)
if checked_permission is not None:
checkPermission = getSecurityManager().checkPermission
object_list = [o for o in object_list if checkPermission(checked_permission, o)]
object_list = sortValueList(object_list, sort_on, sort_order, **kw)
filter_kw = kw.pop('filter', None) or {}
portal_type_id_list = self._getTypesTool().objectIds()
if 'portal_type' in filter_kw:
portal_type = filter_kw.pop('portal_type')
if isinstance(portal_type, str):
portal_type = portal_type,
kw['portal_type'] = [x for x in portal_type if x in portal_type_id_list]
elif 'portal_type' not in kw:
kw['portal_type'] = portal_type_id_list
object_list = self.objectValues(*args, **kw)
if filter_kw:
object_list = filter(ContentFilter(**filter_kw), object_list)
return object_list
# Override security declaration of CMFCore/PortalFolder (used by CMFBTreeFolder)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment