Commit fd67a7d4 authored by Nicolas Delaby's avatar Nicolas Delaby

Extend Constraint definition to support additional parameters, approved by jerome

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31954 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 39973a1a
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Sebastien Robin <seb@nexedi.com> # Sebastien Robin <seb@nexedi.com>
# Courteaud Romain <romain@nexedi.com> # Courteaud Romain <romain@nexedi.com>
# #
...@@ -48,11 +49,17 @@ class CategoryRelatedMembershipArity(CategoryMembershipArity): ...@@ -48,11 +49,17 @@ class CategoryRelatedMembershipArity(CategoryMembershipArity):
'base_category' : ('causality',) 'base_category' : ('causality',)
'condition' : 'python: object.getPortalType() == 'Foo', 'condition' : 'python: object.getPortalType() == 'Foo',
}, },
additional parameters passed to catalog are accepted:
'filter_parameter': {'simulation_state': ('planned',)},
""" """
def _calculateArity(self, obj): def _calculateArity(self, obj):
base_category = self.constraint_definition['base_category'] base_category = self.constraint_definition['base_category']
portal_type = self.constraint_definition['portal_type'] sql_kw = {'portal_type': self.constraint_definition['portal_type'],
return len(obj._getRelatedValueList(base_category, '%s_uid' % base_category: obj.getUid()}
portal_type=portal_type)) filter_parameter = self.constraint_definition.get('filter_parameter', {})
sql_kw.update(filter_parameter)
portal = obj.getPortalObject()
return len(portal.portal_catalog.unrestrictedSearchResults(**sql_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