From d7267ffd1cbc6fb456db856e9715c020b0d87a0b Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Mon, 31 May 2010 09:54:37 +0000
Subject: [PATCH] Provide Backward compatibility code for existing type based
 method which doesn't support new **kw parameter.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35772 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/mixin/document.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/product/ERP5/mixin/document.py b/product/ERP5/mixin/document.py
index 1cb3b55987..4d30640d60 100644
--- a/product/ERP5/mixin/document.py
+++ b/product/ERP5/mixin/document.py
@@ -87,7 +87,14 @@ class DocumentMixin:
     # XXX cache result in TV
     method = self._getTypeBasedMethod('checkConversionFormatPermission',
                  fallback_script_id='Document_checkConversionFormatPermission')
-    if not method(format=format, **kw):
+    if '**kw' not in method.params():
+      # Backward compatibility code:
+      # Existing Type Based Method doesn't support new **kw argument
+      # in their signature.
+      is_allowed = method(format=format)
+    else:
+      is_allowed = method(format=format, **kw)
+    if not is_allowed:
       raise Unauthorized('Document: user does not have enough permission'\
                          ' to access document in %s format' %\
                                                         (format or 'original'))
-- 
2.30.9