This quick patch changes the XML-RPC signature to match the
complementary change being made in certmonger.

The signature is now:

    [args, options]

This doesn't yet include the [args, options, extra] change... that is
coming in my rpcserver patch once it's done.  But this provides what
needed for current IPA <=> certmonger compatibility.
>From b802442d7a62ac6f9a87a87bd6ed58623cbb2f09 Mon Sep 17 00:00:00 2001
From: Jason Gerard DeRose <jder...@redhat.com>
Date: Fri, 26 Mar 2010 03:56:53 -0600
Subject: [PATCH] XML-RPC signature change

---
 ipalib/rpc.py                          |    2 +-
 ipaserver/rpcserver.py                 |    7 +++----
 tests/test_ipalib/test_rpc.py          |    2 +-
 tests/test_ipaserver/test_rpcserver.py |    6 ++----
 4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index 62f1d77..e7f3338 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -401,7 +401,7 @@ class xmlclient(Connectible):
             )
         self.info('Forwarding %r to server %r', name, self.env.xmlrpc_uri)
         command = getattr(self.conn, name)
-        params = args + (kw,)
+        params = [args, kw]
         try:
             response = command(*xml_wrap(params))
             return xml_unwrap(response)
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 967ee33..657f5fb 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -72,12 +72,11 @@ def read_input(environ):
 
 
 def params_2_args_options(params):
-    assert type(params) is tuple
     if len(params) == 0:
         return (tuple(), dict())
-    if type(params[-1]) is dict:
-        return (params[:-1], params[-1])
-    return (params, dict())
+    if len(params) == 1:
+        return (params[0], dict())
+    return (params[0], params[1])
 
 
 def nicify_query(query, encoding='utf-8'):
diff --git a/tests/test_ipalib/test_rpc.py b/tests/test_ipalib/test_rpc.py
index 83092b5..a87b65a 100644
--- a/tests/test_ipalib/test_rpc.py
+++ b/tests/test_ipalib/test_rpc.py
@@ -204,7 +204,7 @@ class test_xmlclient(PluginTester):
         (o, api, home) = self.instance('Backend', user_add, in_server=False)
         args = (binary_bytes, utf8_bytes, unicode_str)
         kw = dict(one=binary_bytes, two=utf8_bytes, three=unicode_str)
-        params = args + (kw,)
+        params = [args, kw]
         result = (unicode_str, binary_bytes, utf8_bytes)
         conn = DummyClass(
             (
diff --git a/tests/test_ipaserver/test_rpcserver.py b/tests/test_ipaserver/test_rpcserver.py
index 294d349..2f52662 100644
--- a/tests/test_ipaserver/test_rpcserver.py
+++ b/tests/test_ipaserver/test_rpcserver.py
@@ -79,10 +79,8 @@ def test_params_2_args_options():
     args = ('Hello', u'world!')
     options = dict(one=1, two=u'Two', three='Three')
     assert f(tuple()) == (tuple(), dict())
-    assert f(args) == (args, dict())
-    assert f((options,)) == (tuple(), options)
-    assert f(args + (options,)) == (args, options)
-    assert f((options,) + args) == ((options,) + args, dict())
+    assert f([args]) == (args, dict())
+    assert f([args, options]) == (args, options)
 
 
 class test_session(object):
-- 
1.7.0

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to