Commit 2b20a1d8 authored by Vincent Pelletier's avatar Vincent Pelletier

CMFCategory.CategoryTool: Stop using selection_{report,domain}

It is overkill, and is likely slower than just passing the needed
values straight to catalog.
Also, rely on duck-typing instad of portal-type-testing.
Also, drop unused "spec" and "filter" arguments.
Also, expose strict{,_membership} used arguments, simplifying code.
Keep catchall **kw for compatibility.
parent eef44f66
No related merge requests found
......@@ -1624,27 +1624,23 @@ class CategoryTool( UniqueObject, Folder, Base ):
return result
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberValueList' )
def getCategoryMemberValueList(self, context, base_category = None,
spec = (), filter=None, portal_type=(), **kw):
def getCategoryMemberValueList(self, context, base_category=None,
portal_type=(), strict_membership=False, strict=False, **kw):
"""
This returns a catalog_search resource with can then be used by getCategoryMemberItemList
"""
if base_category is None:
if context.getPortalType() in ( "Base Category", "Category") :
base_category = context.getBaseCategoryId()
else:
raise CategoryError('getCategoryMemberValueList must know the base category')
strict_membership = kw.get('strict_membership', kw.get('strict', 0))
domain_dict = {base_category: ('portal_categories', context.getRelativeUrl())}
if strict_membership:
catalog_search = self.portal_catalog(portal_type = portal_type,
selection_report = domain_dict)
else:
catalog_search = self.portal_catalog(portal_type = portal_type,
selection_domain = domain_dict)
return catalog_search
sql_kw = {
(
'strict_'
if strict_membership or strict else
'default_'
) + base_category + '_uid': context.getUid(),
}
if portal_type:
sql_kw['portal_type'] = portal_type
return self.getPortalObject().portal_catalog(**sql_kw)
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberItemList' )
def getCategoryMemberItemList(self, context, **kw):
......
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