[Erp5-report] r31725 jm - /erp5/trunk/products/ERP5/Document/Alarm.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jan 13 15:11:47 CET 2010


Author: jm
Date: Wed Jan 13 15:11:45 2010
New Revision: 31725

URL: http://svn.erp5.org?rev=31725&view=rev
Log:
Alarm scripts may accept any parameter with a '**kw' in their signature

This fixes a regression caused by [31668].

Modified:
    erp5/trunk/products/ERP5/Document/Alarm.py

Modified: erp5/trunk/products/ERP5/Document/Alarm.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Alarm.py?rev=31725&r1=31724&r2=31725&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Alarm.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Alarm.py [utf8] Wed Jan 13 15:11:45 2010
@@ -26,6 +26,7 @@
 #
 ##############################################################################
 
+from compiler.consts import CO_VARARGS, CO_VARKEYWORDS
 import zope.interface
 from AccessControl import ClassSecurityInfo
 from AccessControl import Unauthorized
@@ -304,9 +305,18 @@
         # We do some inspection to keep compatibility
         # (because fixit and tag were not set previously)
         tag = str(self.portal_ids.generateNewLengthId(id_group=self.getId()))
-        func_code = getattr(self, method_id).func_code
+        method = getattr(self, method_id)
+        func_code = method.func_code
+        try:
+          has_kw = func_code.co_flags & CO_VARKEYWORDS
+        except AttributeError:
+          # XXX guess presence of *args and **kw
+          name_list = func_code.co_varnames[func_code.co_argcount:]
+          has_args = int(name_list and name_list[0] == 'args')
+          has_kw = int(len(name_list) > has_args and
+                       name_list[has_args] == 'kw')
         name_list = func_code.co_varnames[:func_code.co_argcount]
-        if 'params' in name_list:
+        if 'params' in name_list or has_kw:
           # New New API
           getattr(self.activate(tag=tag), method_id)(fixit=fixit, tag=tag, params=params)
         elif 'fixit' in name_list:




More information about the Erp5-report mailing list