[Erp5-report] r41813 nicolas.dumazet - /erp5/trunk/products/ERP5Type/Core/Predicate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 28 04:02:00 CET 2010


Author: nicolas.dumazet
Date: Tue Dec 28 04:01:59 2010
New Revision: 41813

URL: http://svn.erp5.org?rev=41813&view=rev
Log:
add tales expression to a predicate so that one can define simple conditions
without having to create dozens of unique Python scripts.


Modified:
    erp5/trunk/products/ERP5Type/Core/Predicate.py

Modified: erp5/trunk/products/ERP5Type/Core/Predicate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/Predicate.py?rev=41813&r1=41812&r2=41813&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/Predicate.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Core/Predicate.py [utf8] Tue Dec 28 04:01:59 2010
@@ -44,6 +44,7 @@ from Products.ERP5Type.Cache import getR
 from Products.ZSQLCatalog.SQLCatalog import SQLQuery
 from Products.ERP5Type.Globals import PersistentMapping
 from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
+from Products.CMFCore.Expression import Expression
 
 class Predicate(XMLObject):
   """
@@ -207,6 +208,12 @@ class Predicate(XMLObject):
 #              '%s after method %s ' % (result, test_method_id))
           if not result:
             return result
+    test_tales_expression = self.getTestTalesExpression()
+    if test_tales_expression not in (None, '', 'python: True'):
+      expression = Expression(test_tales_expression)
+      from Products.ERP5Type.Utils import createExpressionContext
+      # evaluate a tales expression with the tested value as context
+      result = expression(createExpressionContext(context))
     return result
 
   @UnrestrictedMethod



More information about the Erp5-report mailing list