-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SimpleXMLRPCServer.SimpleXMLRPCServer.register_function as decorator #52017
Comments
I would suggest to make SimpleXMLRPCServer.SimpleXMLRPCServer.register_function a decorator function. So as far as I've tested it (py2.6), it is fully backwards compatible and supports decorators in addition. |
Can you submit your patch as a unified diff -- it's not easy to tell where you made changes to that file. |
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/ |
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. |
OK, thank you for the links! Do you still want me to do anything (like test cases etc.)? |
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. |
OK, will work on it and reply as soon as I have results! |
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. |
Santoso - since this is a feature request it would need to be retargeted to 3.3 |
I see. Attaching a patch against 3.3 tip, then. |
sorry, I totally forgot about this... |
Here's some quick review comments:
|
Hi, I've written a patch to accomplish this in Py3.6. This patch is much cleaner but has one drawback, when used as decorator factory, you have to specify name as a keyword argument. But considering the codes that have to been imported to check arguments, I think it's not bad. (I don't want to check Also one side effect that I can not eliminate is when it is used as a normal function, the function instead of None is returned. I see the former patches get this problem too. Hope to get feedback. |
ping |
I don't have an opinion about needing this feature. But for accepting it needs more documenting. The signature should be updated, the new feature should be documented in the main text, not only in the versionchanged note. Needed examples of using egister_function as decorator. |
From the old comments from Brian it seems he's willing to accept such a feature. But unfortunately Brian seems not interested in this now. IMHO, this is good feature especially to people familiar with Bottle and Flask. Writing in a decorator way seems more elegant to me. Nevertheless, add more doc. |
I think this does not matter after seeing functools.singledispatch. The versionadded tags should be changed to versionchanged in my last patch. |
+1 for the decorator idea. It feels very natural. A little off topic, I do not like the with-statement example that we currently have in the docs. I think it is bad design to put some much code inside with-block. In the micro-webframeworks, we register functions separately from launching the server. The same practice should apply here as well. |
Thanks Raymond. I would like to keep the example style another issue, not this one. :-) And I hope someone is willing to review the PR. |
Thanks everyone involved! |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: