hello python developers,

i recently started working on a simple xml rpc application, the simple version is completly working but when i wanted to extend it and add some more functionality i ran into some troubles.

i want to register functions from different classes as server methods, i thought i could use server.register_instance() for that purpose unfortanatly i was mistaken.

class MyFunc:
     def divide(self,x,y):
          return x // y

class MyFunc2:
     def multiply(self,x,y):
          return x * y


this is part of the code which i thought would do the job, now when i list all my server methods i only see the function of the last class i added (multiply in this case ), i also tried the following way


but that was also unsuccesfull.

another option would be to register every function seperatly but when i have a lot of classes with different functions that can only serve as work around if nothing else works.

does anyone know a better solution for this problem,

every suggestion would be greatly appreciated,

Richard Mendes

Sorry for reviving such and ancient thread, but I had exactly the same problem and this thread came up on third place in a google search.

The solution I used was creating a new class on the fly using "type".

This new class uses the two classes you want to combine as parent or super classes so that it inherits the methods of both.

In this case this would look like this:

server.register_instance(type('newclass', (MyFunc1, MyFunc2), {})())

Hope this helps someone who finds this thread.

commented: Kind of you! +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.