Commit 28cf8c75 authored by Romain Courteaud's avatar Romain Courteaud

Allow to convert the "filter_parameter" parameter.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43159 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 28f85474
...@@ -75,3 +75,39 @@ class CategoryRelatedMembershipArityConstraint(CategoryMembershipArityConstraint ...@@ -75,3 +75,39 @@ class CategoryRelatedMembershipArityConstraint(CategoryMembershipArityConstraint
portal = obj.getPortalObject() portal = obj.getPortalObject()
return len(portal.portal_catalog.unrestrictedSearchResults(**sql_kw)) return len(portal.portal_catalog.unrestrictedSearchResults(**sql_kw))
@staticmethod
def _convertFromFilesystemDefinition(min_arity,
portal_type=(),
max_arity=None,
base_category=(),
filter_parameter=None):
"""
@see ERP5Type.mixin.constraint.ConstraintMixin._convertFromFilesystemDefinition
Filesystem definition example:
{ 'id' : 'source',
'description' : '',
'type' : 'CategoryMembershipArity',
'min_arity' : '1',
'max_arity' : '1',
'portal_type' : ('Organisation', ),
'base_category' : ('source',)
'condition' : 'python: object.getPortalType() == 'Foo',
}
"""
constraint_portal_type_str = isinstance(portal_type, Expression) and \
portal_type.text or 'python: ' + repr(portal_type)
zodb_property_dict = dict(
min_arity=int(min_arity),
constraint_portal_type=constraint_portal_type_str,
constraint_base_category_list=base_category)
if max_arity is not None:
zodb_property_dict['max_arity'] = int(max_arity)
if filter_parameter is not None:
zodb_property_dict['filter_parameter'] = filter_parameter
yield zodb_property_dict
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