From d0f89f1a8f7e8662759f13ed1f2efbea8b1c155c Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Mon, 19 Apr 2010 12:09:55 +0000
Subject: [PATCH] Make isDelivery/isMovement usable as predicate test method

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34650 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Predicate.py    | 3 ++-
 product/ERP5Type/Accessor/Constant.py | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/product/ERP5/Document/Predicate.py b/product/ERP5/Document/Predicate.py
index f13de610fb..ba68b5243b 100644
--- a/product/ERP5/Document/Predicate.py
+++ b/product/ERP5/Document/Predicate.py
@@ -27,6 +27,7 @@
 #
 ##############################################################################
 
+from types import MethodType
 import zope.interface
 from warnings import warn
 from AccessControl import ClassSecurityInfo
@@ -187,7 +188,7 @@ class Predicate(XMLObject):
           try:
             result = result and method(self)
           except TypeError:
-            if method.func_code.co_argcount != 0:
+            if method.func_code.co_argcount != isinstance(method, MethodType):
               raise
             # backward compatibilty with script that takes no argument
             warn('Predicate %s uses an old-style method (%s) that does not'
diff --git a/product/ERP5Type/Accessor/Constant.py b/product/ERP5Type/Accessor/Constant.py
index 924be35203..745def871d 100644
--- a/product/ERP5Type/Accessor/Constant.py
+++ b/product/ERP5Type/Accessor/Constant.py
@@ -38,6 +38,10 @@ class PropertyGetter:
   issues when we wish to make a property a method. For instance,
   we would like to change from isIndexable=1 to a method isIndexable().
   """
+  func_code = func_code()
+  func_code.co_varnames = ()
+  func_code.co_argcount = 0
+  func_defaults = ()
 
   def __init__(self, id, value=None):
     self._id = id
-- 
2.30.9