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
...@@ -1624,27 +1624,23 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1624,27 +1624,23 @@ class CategoryTool( UniqueObject, Folder, Base ):
return result return result
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberValueList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberValueList' )
def getCategoryMemberValueList(self, context, base_category = None, def getCategoryMemberValueList(self, context, base_category=None,
spec = (), filter=None, portal_type=(), **kw): portal_type=(), strict_membership=False, strict=False, **kw):
""" """
This returns a catalog_search resource with can then be used by getCategoryMemberItemList This returns a catalog_search resource with can then be used by getCategoryMemberItemList
""" """
if base_category is None: if base_category is None:
if context.getPortalType() in ( "Base Category", "Category") :
base_category = context.getBaseCategoryId() base_category = context.getBaseCategoryId()
else: sql_kw = {
raise CategoryError('getCategoryMemberValueList must know the base category') (
strict_membership = kw.get('strict_membership', kw.get('strict', 0)) 'strict_'
if strict_membership or strict else
domain_dict = {base_category: ('portal_categories', context.getRelativeUrl())} 'default_'
if strict_membership: ) + base_category + '_uid': context.getUid(),
catalog_search = self.portal_catalog(portal_type = portal_type, }
selection_report = domain_dict) if portal_type:
else: sql_kw['portal_type'] = portal_type
catalog_search = self.portal_catalog(portal_type = portal_type, return self.getPortalObject().portal_catalog(**sql_kw)
selection_domain = domain_dict)
return catalog_search
security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberItemList' ) security.declareProtected( Permissions.AccessContentsInformation, 'getCategoryMemberItemList' )
def getCategoryMemberItemList(self, context, **kw): 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