Commit 78c5fce6 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Make getPathValueList easier to debug.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34988 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 65264349
...@@ -80,21 +80,30 @@ class BusinessProcess(Path, XMLObject): ...@@ -80,21 +80,30 @@ class BusinessProcess(Path, XMLObject):
**kw -- same parameters as for searchValues / contentValues **kw -- same parameters as for searchValues / contentValues
""" """
# Naive implementation to redo XXX using contentValues
if trade_phase is None: if trade_phase is None:
trade_phase = [] trade_phase = set()
elif not isinstance(trade_phase, (list, tuple)): elif not isinstance(trade_phase, (list, tuple)):
trade_phase = (trade_phase,) trade_phase = set((trade_phase,))
else:
trade_phase = set(trade_phase)
result = [] result = []
if len(trade_phase) == 0: if len(trade_phase) == 0:
return result return result
business_path_list = sorted(self.objectValues(portal_type="Business Path"), # Separate the selection of business paths into twp steps
key=lambda x:x.getIntIndex()) # for easier debugging.
trade_phase = set(trade_phase) # First, collect business paths which can be applicable to a given context.
for document in business_path_list: business_path_list = []
if trade_phase.intersection(document.getTradePhaseList()) and \ for business_path in self.objectValues(portal_type='Business Path',
document.test(context): sort_on='int_index'):
result.append(document) if trade_phase.intersection(business_path.getTradePhaseList()):
business_path_list.append(business_path)
# Then, filter business paths by Predicate API.
# FIXME: Ideally, we should use the Domain Tool to search business paths,
# and avoid using the low level Predicate API. But the Domain Tool does
# support the condition above without scripting?
for business_path in business_path_list:
if business_path.test(context):
result.append(business_path)
return result return result
security.declareProtected(Permissions.AccessContentsInformation, 'getStateValueList') security.declareProtected(Permissions.AccessContentsInformation, 'getStateValueList')
......
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