python decorations

hrotzing at hrotzing at
Fri Jun 9 08:38:43 PDT 2006

Hi all,

I'm quite new to dbus and python but I want to use the python dbus bindings to 
write a few programs which communicate over dbus.
All these small programs should use a python base class similar to this 

class  service(dbus.service.Object):
	def __init__(self,ServiceName):
			bus = dbus.Bus()	
			bus_name = dbus.service.BusName(ServiceName,
			dbus.service.Object.__init__(self, bus_name,InterfaceServiceName)
      	# a set of  default functions for every inherited object, e.g.
	def EchoString(self, original):
		return original

and inherit this class in this way 

class MySubClass(service):
        def func(self):
                return "foo"

service_obj = MySubClass(ServiceName)

This works, if the ServiceName is set statically before the service class gets 

Setting the ServiceName in the __init_() func of the service class like above 
did not work. The @dbus.service.method(MyServiceName) decoration is always 
throwing exceptions, usually from the 
_util._validate_interface_or_name(dbus_interface)  function showing that the 
string MyServiceName was not set.

Is it possible to modify the @dbus.service.method(MyServiceName) decoration at 
run time ? If I would use a static bus_interface, all objects would use the 
same bus_interface name on the bus.

Thank you for your answer,

More information about the dbus mailing list