Commit d0f89f1a authored by Julien Muchembled's avatar Julien Muchembled

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
parent 4837342c
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# #
############################################################################## ##############################################################################
from types import MethodType
import zope.interface import zope.interface
from warnings import warn from warnings import warn
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -187,7 +188,7 @@ class Predicate(XMLObject): ...@@ -187,7 +188,7 @@ class Predicate(XMLObject):
try: try:
result = result and method(self) result = result and method(self)
except TypeError: except TypeError:
if method.func_code.co_argcount != 0: if method.func_code.co_argcount != isinstance(method, MethodType):
raise raise
# backward compatibilty with script that takes no argument # backward compatibilty with script that takes no argument
warn('Predicate %s uses an old-style method (%s) that does not' warn('Predicate %s uses an old-style method (%s) that does not'
......
...@@ -38,6 +38,10 @@ class PropertyGetter: ...@@ -38,6 +38,10 @@ class PropertyGetter:
issues when we wish to make a property a method. For instance, issues when we wish to make a property a method. For instance,
we would like to change from isIndexable=1 to a method isIndexable(). 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): def __init__(self, id, value=None):
self._id = id self._id = id
......
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