[Patches] [ python-Patches-1374063 ] Broader iterable support for xmlrpclib
SourceForge.net
noreply at sourceforge.net
Tue Dec 6 05:23:50 CET 2005
Patches item #1374063, was opened at 2005-12-05 22:14
Message generated for change (Comment added) made by montanaro
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1374063&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: Broader iterable support for xmlrpclib
Initial Comment:
The XML-RPC spec supports a fairly limited set of datatypes.
Most languages, Python included, contain many more types
than XML-RPC. Some types, such as Python's complex number
type, have no reasonable analog in XML-RPC. Others, such as
unicode objects and array objects do. This patch allows
anything that can be converted to a list but that is not
otherwise supported directly by the xmlrpclib module already
to be marshalled as an XML-RPC array if the allow_iter
parameter to the ServerProxy constructor evaluated to true.
This includes sets and arrays.
Motivation...
1. Python already overloads the XML-RPC array type with both
lists and tuples. This just extends that overloading to
other currently unsupported Python types which can be
converted to lists. Why should lists and tuples have all the
fun?
2. Providing transparent conversion to XML-RPC arrays keeps
calling code a bit cleaner. One of the attractions of
XML-RPC is that the remote procedure call looks identical
to a local call. This is especially true in Python
because of /F's excellent little _Method class. Clearly
as a programmer I could type:
import array
a = array.array('i', [1, 2,3])
...
from somemodule import somefunction
print somefunction(list(a))
but that reveals details of the implementation of
somefunction, namely that it can't handle arrays
directly, even though in most respects arrays
and lists are interchangeable.
Attached is a patch for the xmlrpclib library that
implements this feature, including minor doc changes and a
new test case.
----------------------------------------------------------------------
>Comment By: Skip Montanaro (montanaro)
Date: 2005-12-05 22:23
Message:
Logged In: YES
user_id=44345
Oh, I forgot my original use case. I was constructing a list of musicians
from a larger data structure and used a set to guarantee uniqueness
during construction. I didn't really care about element ordering. I
either had to convert the set to a list when calling the local function
that made the RPC call, or modify the local function to always convert
that arg to a list. Both alternatives seemed unattractive to me.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1374063&group_id=5470
More information about the Patches
mailing list