Pyrhon binding
Marcin
marcino_l at o2.pl
Thu Mar 2 06:59:41 PST 2006
On Thu, 02 Mar 2006 14:55:12 +0100, Robert McQueen
<robert.mcqueen at collabora.co.uk> wrote:
> Marcin wrote:
>> Hi,
>> It is posible to add method to existing interface?
> ..
>> If I creating object of calss WithinObject the object should add a
>> method "methodW" do interface 'com.ObjectService.Interface', but it
>> doesn't work. What should I do? How should the class WithinObject be
>> written?
>
> Make WithinObject extend ObjectService, or make it extend
> dbus.service.Interface and make some other object that inherits from
> both ObjectService and WithinObject. You can't do what you tried, which
> is to make two Python object instances implement different parts of a
> single D-Bus object.
>
> Note that whilst it's allowable to make different instances of an
> interface implement different methods, it's confusing and unlikely to
> map well to other language bindings. If you want an object that
> sometimes has some extra methods, and sometimes doesn't, put those
> methods in a different interface.
>
>> Thanks for help.
>>
>> Marcin
>
> Regards,
> Rob
>
I haven't understood everything, but I have next question for You.
class WithinObject1:
def __init__(self):
...
@dbus.service.method('com.ObjectService.Interface')
def methodW1(self):
print 'Hello from WittinObject1 class '
class WithinObject2:
def __init__(self):
...
@dbus.service.method('com.ObjectService.Interface')
def methodW2(self):
print 'Hello from WittinObject2 class '
class Listener:
def __init__(self):
self.sevice = ObjectService()
wobj1 = WithinObject1()
wobj2 = WithinObject2()
What would you do in that case? Inherit from ObjectService is impossible
because you will create two services with the same name. Methods methodW1
and methodW2 have to be in the same interface.
Marcin
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the dbus
mailing list