Commit a89bf3a0 authored by Vincent Pelletier's avatar Vincent Pelletier

CatalogTool: Extend "parent" support in getCategoryValueDictParameterDict

parent 8623938d
...@@ -1086,12 +1086,36 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -1086,12 +1086,36 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
}), }),
) )
if parent_document_set is not None: if parent_document_set is not None:
if forward:
if strict_membership:
query_list.append(SimpleQuery( query_list.append(SimpleQuery(
parent_uid={ parent_uid={
document.getUid() document.getUid()
for document in parent_document_set for document in parent_document_set
}, },
)) ))
else:
query_list.append(SimpleQuery(
path={
x.getPath().replace('_', r'\_').replace('%', r'\%') + '/%'
for x in parent_document_set
},
comparison_operator='like',
))
else:
parent_uid_set = {
document.getUid()
for document in parent_document_set
}
if not strict_membership:
for document in parent_document_set:
while True:
document = document.getParentValue()
uid = getattr(document, 'getUid', lambda: None)()
if uid is None:
break
parent_uid_set.add(uid)
query_list.append(SimpleQuery(uid=parent_uid_set))
return ComplexQuery(query_list) return ComplexQuery(query_list)
security.declarePublic('getCategoryParameterDict') security.declarePublic('getCategoryParameterDict')
......
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