From cd50a7aaaddec41d26b7a2387f6074ef105f9dbc Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Mon, 11 Aug 2014 20:11:42 +0200 Subject: [PATCH] asPredicate() can be customized at class level by overriding _asPredicate() --- product/ERP5Type/Core/Predicate.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/product/ERP5Type/Core/Predicate.py b/product/ERP5Type/Core/Predicate.py index e173bd4cb8..fce57df31e 100644 --- a/product/ERP5Type/Core/Predicate.py +++ b/product/ERP5Type/Core/Predicate.py @@ -586,22 +586,23 @@ class Predicate(XMLObject): security.declareProtected(Permissions.AccessContentsInformation, 'asPredicate') - def asPredicate(self, script_id=None): + def asPredicate(self): """ This method tries to convert the current Document into a predicate looking up methods named Class_asPredicate, MetaType_asPredicate, PortalType_asPredicate """ cache = getTransactionalVariable() - key = 'asPredicate', self, script_id + key = 'asPredicate', self try: return cache[key] except KeyError: - script = self._getTypeBasedMethod('asPredicate', script_id) - if script is not None: - self = script() + self = self._getTypeBasedMethod("asPredicate", "_asPredicate")() cache[key] = self return self + def _asPredicate(self): + return self + def searchPredicate(self, **kw): """ Returns a list of documents matching the predicate -- 2.30.9