mosquito / aiohttp-xmlrpc

XMLRPC for aiohttp
MIT License
34 stars 19 forks source link

Allow nested methods to be called on client side #48

Closed ArmandBENETEAU closed 2 years ago

ArmandBENETEAU commented 2 years ago

The code modification done here is largely inspired by what is done in the 'xmlrpc' built-in python library.

The code mechanism is about creating a "_Method" class that handle the "nested" calls (e.g. A.foo()).

In order to keep the close() method as it was before, an exception is added in the __getattr__() function of the ServerProxy class.

Signed-off-by: Armand Bénéteau armand.beneteau@iot.bzh

mosquito commented 2 years ago

Good job, but now it remains to finalize the server part so that you can write tests and you have to write tests.

ArmandBENETEAU commented 2 years ago

Good job, but now it remains to finalize the server part so that you can write tests and you have to write tests.

Yeah, I agree with that at 100%!

But as I've said, I have task with higher priority right now in my company, so I guess that this pull request will have to wait until beginning of 2022.

mosquito commented 2 years ago

Unfortunately, these changes broke the existing tests.

ArmandBENETEAU commented 2 years ago

Unfortunately, these changes broke the existing tests.

Yeah, I will try to have a look on what is breaking the test...

ArmandBENETEAU commented 2 years ago

This new commit should fix the tests. Indeed I made a mistake in the __call__ method of _Method class.

m-bucher commented 2 years ago

IMHO this change also requires a change in the README.md, because the current client-example no longer works:

    # Or via __getitem__
    method = client['args']
    print(await method(1, 2, 3))

Or am I missing something?

ArmandBENETEAU commented 2 years ago

@m-bucher Oups! Indeed you are right, since we are not using the __getitem__ function anymore, this example is broken... We could replace this part of README.md by:

print(await client.args(1, 2, 3))