This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make custom xmlrpc extension easier
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: bogdan.opanchuk, draghuram, ggenellina, kristjan.jonsson, loewis
Priority: normal Keywords: patch

Created on 2009-08-14 09:03 by bogdan.opanchuk, last changed 2022-04-11 14:56 by admin.

Files
File name Uploaded Description Edit
patch.diff bogdan.opanchuk, 2009-08-14 09:04 Patch for client.py, server.py and test_xmlrpc.py
client.py bogdan.opanchuk, 2009-08-14 09:04 changed client.py
server.py bogdan.opanchuk, 2009-08-14 09:05 changed server.py
test_xmlrpc.py bogdan.opanchuk, 2009-08-14 09:05 changed test_xmlrpc.py
xmlrpc_overload.py bogdan.opanchuk, 2009-08-14 09:06 Example of usage
Messages (4)
msg91546 - (view) Author: Bogdan Opanchuk (bogdan.opanchuk) Date: 2009-08-14 09:03
I am sorry if the same issue was already considered and rejected for
some reason; quick search did not show any traces of it.

What I am going to write here is just a proof of concept, but if the
idea of the patch is acceptable, I am eager to prepare proper patches
for lib, documentation and so on.

So, my aim was to make xmlrpc module frendlier to those who want to
extend its functionality locally in their own projects. Currently there
are several problems with it:
1. Marshaller, unmarshaller and parser cannot be substituted by custom
versions easily.
2. Custom version of marshaller will look ugly (i.e., because it may
need to call Marshaller.__dump)
3. Transport, parser and unmarshaller are coupled now, though they are
completely independent.

My patch seem to eliminate these problems (see attach). Briefly, it
contains the following changes:
1. Transport, parser and unmarshaller are decoupled
2. Custom masrshaller, parser and unmarshaller classes can be passed to
client and server classes as parameters
3. Made Marshaller class easier to extend:
- __dump() renamed to _dump()
- added _add_memo() and _del_memo() (and hid .memo field)
- memo is now a set() (instead of dictionary with None values)
- dispatch table was made private

Results:
(good) This patch does not invalidate any part of documentation (but it
needs to be extended, according to new marshaller/unmarshaller/parser
parameters)
(good) test_xmlrpc still passes (with one little change to it, patch is
attached)
(good) Extension is easy now - see xmlrpc_overload.py as an example
(added bytes(), tuple() and dict() with non-string keys support)
(bad) Programs which use exported, but undocumented parts of xmlrpc can
break (though most of them can be easily fixed)
msg101624 - (view) Author: Gabriel Genellina (ggenellina) Date: 2010-03-24 07:53
Just a few comments on the code itself:

    if type_ in self.__dispatch.keys():
should be:
    if type_ in self.__dispatch:

Previously, error reporting of recursive data stated the type of the offending value; with this patch, this hint is lost (see _add_memo)

Caching of bound methods in local variables is a common optimization (dump=self._dump); why did you remove it everywhere?

Why Marshaller.dispatch was renamed to __dispatch but Unmarshaller.dispatch stays the same? (btw, why the double underscore?)
msg101625 - (view) Author: Gabriel Genellina (ggenellina) Date: 2010-03-24 07:53
Just a few comments on the code itself:

    if type_ in self.__dispatch.keys():
should be:
    if type_ in self.__dispatch:

Previously, error reporting of recursive data stated the type of the offending value; with this patch, this hint is lost (see _add_memo)

Caching of bound methods in local variables is a common optimization (dump=self._dump); why did you remove it everywhere?

Why Marshaller.dispatch was renamed to __dispatch but Unmarshaller.dispatch stays the same? (btw, why the double underscore?)
msg219977 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-07 21:20
Is there any value in the proof of concept patches attached here?
History
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50950
2019-03-15 22:39:51BreamoreBoysetnosy: - BreamoreBoy
2015-03-01 17:04:27BreamoreBoysetnosy: + loewis

versions: + Python 3.5, - Python 3.2
2014-06-07 21:20:12BreamoreBoysetnosy: + BreamoreBoy
messages: + msg219977
2010-03-24 07:53:42ggenellinasetmessages: + msg101625
2010-03-24 07:53:37ggenellinasetnosy: + ggenellina
messages: + msg101624
2009-08-25 11:27:36ezio.melottisetpriority: normal
nosy: + kristjan.jonsson
2009-08-14 13:34:09draghuramsetnosy: + draghuram
2009-08-14 09:06:06bogdan.opanchuksetfiles: + xmlrpc_overload.py
2009-08-14 09:05:31bogdan.opanchuksetfiles: + test_xmlrpc.py
2009-08-14 09:05:11bogdan.opanchuksetfiles: + server.py
2009-08-14 09:04:54bogdan.opanchuksetfiles: + client.py
2009-08-14 09:04:28bogdan.opanchuksetfiles: + patch.diff
keywords: + patch
2009-08-14 09:03:47bogdan.opanchukcreate