classification
Title: SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ahojnnes, brian.curtin, santa4nt
Priority: normal Keywords: patch

Created on 2010-01-24 12:48 by ahojnnes, last changed 2011-03-09 09:09 by ahojnnes.

Files
File name Uploaded Description Edit
SimpleXMLRPCServer.py ahojnnes, 2010-01-24 12:48 SimpleXMLRPCServer.py
xmlrpc_register_decorator_py27.patch santa4nt, 2011-03-09 02:53 register_function as a decorator and unittest usage review
xmlrpc_register_decorator_py33.patch santa4nt, 2011-03-09 03:29 decorator implementation and unittest usage review
Messages (11)
msg98219 - (view) Author: Johannes Schönberger (ahojnnes) Date: 2010-01-24 12:48
I would suggest to make SimpleXMLRPCServer.SimpleXMLRPCServer.register_function a decorator function.
See the attached file for the solution I wrote (l.209-240), which also works with the current syntax:
@server.register_function
@server.register_function('name')
@server.register_function(name='name')
or:
server.register_function(func)
server.register_function(func, name='name')
server.register_function(function=func, name='name')

So as far as I've tested it (py2.6), it is fully backwards compatible and supports decorators in addition.
msg98230 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-24 16:23
Can you submit your patch as a unified diff -- it's not easy to tell where you made changes to that file. 
Can you also include tests showing how this is used, especially using register_function in both the old way and the new way you propose? Lib/test/test_xmlrpc.py is a good place to put your tests.
msg98233 - (view) Author: Johannes Schönberger (ahojnnes) Date: 2010-01-24 16:47
I'm not very used to working with bug/issue trackers, is there any tutorial here, where this is explained?

I did the stuff you asked me to do:

diff: http://paste.pocoo.org/compare/169357/169359/
test: http://paste.pocoo.org/show/169360/
msg98236 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-24 17:00
http://www.python.org/dev/workflow/ and http://python.org/dev/faq/ should help you get started. The workflow doc will let you know what the process is around here. The FAQ will tell you how to setup Subversion, how to make a diff, etc.

With that said, I think your change could be useful. Being that it's a feature request, it will go into 2.7 if accepted.
msg98238 - (view) Author: Johannes Schönberger (ahojnnes) Date: 2010-01-24 17:09
OK, thank you for the links!

Do you still want me to do anything (like test cases etc.)?
msg98239 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-24 17:19
Once you get a Subversion checkout of the source, have a look in Lib/test/test_xmlrpc.py for examples of how things are currently tested (using unittest). Once you get a feel for it, add new tests for what your changes do. The file you paste'd looks good as an example, you just have to make actual tests out of it now.
msg98241 - (view) Author: Johannes Schönberger (ahojnnes) Date: 2010-01-24 17:21
OK, will work on it and reply as soon as I have results!
msg130403 - (view) Author: Santoso Wijaya (santa4nt) Date: 2011-03-09 02:53
I'm attaching a patch against 2.7 tip for an initial implementation of this decorator feature as well as sample usage in unittest, to get the ball rolling.

The modified function should work as a decorator while preserving backward compatibility to be used in a traditional method call.
msg130406 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011-03-09 03:04
Santoso - since this is a feature request it would need to be retargeted to 3.3
msg130411 - (view) Author: Santoso Wijaya (santa4nt) Date: 2011-03-09 03:29
I see. Attaching a patch against 3.3 tip, then.
msg130433 - (view) Author: Johannes Schönberger (ahojnnes) Date: 2011-03-09 09:09
sorry, I totally forgot about this...
History
Date User Action Args
2011-03-09 09:09:32ahojnnessetnosy: brian.curtin, ahojnnes, santa4nt
messages: + msg130433
2011-03-09 03:29:19santa4ntsetfiles: + xmlrpc_register_decorator_py33.patch
nosy: brian.curtin, ahojnnes, santa4nt
messages: + msg130411
2011-03-09 03:04:19brian.curtinsetnosy: brian.curtin, ahojnnes, santa4nt
messages: + msg130406
versions: + Python 3.3, - Python 2.7
2011-03-09 02:53:54santa4ntsetfiles: + xmlrpc_register_decorator_py27.patch
nosy: brian.curtin, ahojnnes, santa4nt
messages: + msg130403

components: + Library (Lib), - Extension Modules
keywords: + patch
2011-03-08 06:07:40santa4ntsetnosy: + santa4nt
2010-01-24 17:21:01ahojnnessetmessages: + msg98241
2010-01-24 17:19:15brian.curtinsetmessages: + msg98239
2010-01-24 17:09:05ahojnnessetmessages: + msg98238
2010-01-24 17:00:50brian.curtinsetmessages: + msg98236
2010-01-24 16:47:04ahojnnessetmessages: + msg98233
2010-01-24 16:23:33brian.curtinsetpriority: normal
versions: + Python 2.7, - Python 2.6
nosy: + brian.curtin

messages: + msg98230

stage: test needed
2010-01-24 12:48:44ahojnnescreate