0

I now set up a Pydbus server and exported some methods, but one method keeps me guessing. The amount of arguments used in this method is changing. In Python this is simply done with MyMethod(*arg, **kwarg). If I write this function into my XML interface I have to define the exact amount of arguments.

Is there any way to not specify the exact amount of arguments? So that I could in theory use one argument on the first usage and unlimited arguments the second time?

Thanks for your help, Dominik

1 Answers1

0

It would be a lot easier to answer this question concretely if you provided code examples (from the introspection XML) to illustrate the problem.

I’m going to guess that you want MyMethod to be polymorphic. That isn’t a feature of the D-Bus type system by default (all argument lists must be concretely typed).

You can implement this yourself, though, using a single argument of type a{sv}, i.e. MyMethod (a{sv} args). The D-Bus type a{sv} is a dictionary of string keys to variant values, and can contain zero or more such pairs. You can use it to allow a variable number of well-documented argument key/value pairs to be passed to your method.

You might want to read the D-Bus API design guidelines for more hints on how to design good D-Bus APIs.

Philip Withnall
  • 5,293
  • 14
  • 28