Commit 705330b5 authored by Yusei Tahara's avatar Yusei Tahara

Support reference to filter constraints.

parent d1627ffc
......@@ -2540,13 +2540,20 @@ class Base( CopyContainer,
"""
Returns a list of constraints filtered by filt argument.
"""
# currently only 'id' is supported.
# currently only 'id' and 'reference' are supported.
constraints = self.constraints
if filt is not None:
if 'id' in filt:
id_list = filt.get('id', None)
if not isinstance(id_list, (list, tuple)):
id_list = [id_list]
constraints = filter(lambda x:x.id in id_list, constraints)
# New ZODB based constraint uses reference for identity
if 'reference' in filt:
reference_list = filt.get('reference', None)
if not isinstance(reference_list, (list, tuple)):
reference_list = [reference_list]
constraints = filter(lambda x:x.getProperty('reference') in reference_list, constraints)
return constraints
# Context related methods
......
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