[Erp5-report] r26753 - /erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Apr 30 17:36:15 CEST 2009
Author: nicolas
Date: Thu Apr 30 17:36:13 2009
New Revision: 26753
URL: http://svn.erp5.org?rev=26753&view=rev
Log:
Improve Constraint, no need to call portal_catalog. Thanks to jerome
Modified:
erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py
Modified: erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py?rev=26753&r1=26752&r2=26753&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Constraint/AttributeBlacklisted.py [utf8] Thu Apr 30 17:36:13 2009
@@ -37,7 +37,7 @@
{ 'id' : 'title',
'description' : 'Title should not belong to blacklist words',
'type' : 'AttributeBlacklisted',
- 'title' : "python: {'portal_type': object.getPortalType(), 'title': ('Foo', 'Bar',)}",
+ 'title' : "python: ('Foo', 'Bar',)",
'condition' : 'object/getTitle',
},
"""
@@ -50,22 +50,21 @@
def checkConsistency(self, obj, fixit=0):
"""Check the object's consistency.
We will make sure that each non None constraint_definition is
- satisfied (unicity)
- This Constraint use portal_catalog
+ satisfied
"""
if not self._checkConstraintCondition(obj):
return []
errors = PropertyExistence.checkConsistency(self, obj, fixit=fixit)
- for attribute_name, expression_criterion_dict in self.constraint_definition.items():
+ for attribute_name, expression_blaklisted_list in self.constraint_definition.items():
message_id = None
mapping = dict(attribute_name=attribute_name)
#Evaluate expression_criterion_dict
- expression = Expression(expression_criterion_dict)
+ expression = Expression(expression_blaklisted_list)
from Products.ERP5Type.Utils import createExpressionContext
econtext = createExpressionContext(obj)
- criterion_dict = expression(econtext)
- result = obj.portal_catalog.countResults(**criterion_dict)[0][0]
- if result:
+ blaklisted_list = expression(econtext)
+ value = obj.getProperty(attribute_name)
+ if value in blaklisted_list:
message_id = 'message_invalid_attribute_blacklisted'
# Generate error
if message_id is not None:
More information about the Erp5-report
mailing list