Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 46221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:55:55+00:00 2026-05-10T15:55:55+00:00

I have a class that I wish to expose as a remote service using

  • 0

I have a class that I wish to expose as a remote service using pythons SimpleXMLRPCServer. The server startup looks like this:

server = SimpleXMLRPCServer((serverSettings.LISTEN_IP,serverSettings.LISTEN_PORT))  service = Service()  server.register_instance(service) server.serve_forever() 

I then have a ServiceRemote class that looks like this:

def __init__(self,ip,port):     self.rpcClient = xmlrpclib.Server('http://%s:%d' %(ip,port))  def __getattr__(self, name):     # forward all calls to the rpc client     return getattr(self.rpcClient, name) 

So all calls on the ServiceRemote object will be forwarded to xmlrpclib.Server, which then forwards it to the remote server. The problem is a method in the service that takes named varargs:

@useDb def select(self, db, fields, **kwargs):     pass 

The @useDb decorator wraps the function, creating the db before the call and opening it, then closing it after the call is done before returning the result.

When I call this method, I get the error ‘call() got an unexpected keyword argument ‘name”. So, is it possible to call methods taking variable named arguments remotely? Or will I have to create an override for each method variation I need.


Thanks for the responses. I changed my code around a bit so the question is no longer an issue. However now I know this for future reference if I indeed do need to implement positional arguments and support remote invocation. I think a combination of Thomas and praptaks approaches would be good. Turning kwargs into positional args on the client through xmlrpclient, and having a wrapper on methods serverside to unpack positional arguments.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:55:56+00:00Added an answer on May 10, 2026 at 3:55 pm

    You can’t do this with plain xmlrpc since it has no notion of keyword arguments. However, you can superimpose this as a protocol on top of xmlrpc that would always pass a list as first argument, and a dictionary as a second, and then provide the proper support code so this becomes transparent for your usage, example below:

    Server

    from SimpleXMLRPCServer import SimpleXMLRPCServer  class Server(object):     def __init__(self, hostport):         self.server = SimpleXMLRPCServer(hostport)      def register_function(self, function, name=None):         def _function(args, kwargs):             return function(*args, **kwargs)         _function.__name__ = function.__name__         self.server.register_function(_function, name)      def serve_forever(self):         self.server.serve_forever()  #example usage server = Server(('localhost', 8000)) def test(arg1, arg2):     print 'arg1: %s arg2: %s' % (arg1, arg2)     return 0 server.register_function(test) server.serve_forever() 

    Client

    import xmlrpclib  class ServerProxy(object):     def __init__(self, url):         self._xmlrpc_server_proxy = xmlrpclib.ServerProxy(url)     def __getattr__(self, name):         call_proxy = getattr(self._xmlrpc_server_proxy, name)         def _call(*args, **kwargs):             return call_proxy(args, kwargs)         return _call  #example usage server = ServerProxy('http://localhost:8000') server.test(1, 2) server.test(arg2=2, arg1=1) server.test(1, arg2=2) server.test(*[1,2]) server.test(**{'arg1':1, 'arg2':2}) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Yes, sandcastle supports this and it's great to maintain the… May 11, 2026 at 9:59 am
  • added an answer From your comment: Yes, I suppose the question should really… May 11, 2026 at 9:59 am
  • added an answer Google now has the answer for which I seek. With… May 11, 2026 at 9:59 am

Related Questions

I have a class that I wish to expose as a remote service using
I have a class that I want to use to store properties for another
I have a class that I need to binary serialize. The class contains one
I have a class that I am unit testing into with DUnit. It has
I have a class that i want to push_back into a deque. The problem
This is in C#, I have a class that I am using from some
I have a template class that I serialize (call it C), for which I
I have a generic class that I'm trying to implement implicit type casting for.
I have a static class that I would like to raise an event as
I have a JavaScript class that I have made and put it into its

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.