Class Object
source code
object --+
|
Interface --+
|
Object
- Known Subclasses:
-
A base class for exporting your own Objects across the Bus.
Just inherit from Object and mark exported methods with the
@dbus.service.method or @dbus.service.signal decorator.
Example:
class Example(dbus.service.object):
def __init__(self, object_path):
dbus.service.Object.__init__(self, dbus.SessionBus(), path)
self._last_input = None
@dbus.service.method(interface='com.example.Sample',
in_signature='v', out_signature='s')
def StringifyVariant(self, var):
self.LastInputChanged(var) # emits the signal
return str(var)
@dbus.service.signal(interface='com.example.Sample',
signature='v')
def LastInputChanged(self, var):
# run just before the signal is actually emitted
# just put "pass" if nothing should happen
self._last_input = var
@dbus.service.method(interface='com.example.Sample',
in_signature='', out_signature='v')
def GetLastInput(self):
return self._last_input
|
__init__(self,
conn=None,
object_path=None,
bus_name=None)
Constructor. Either conn or bus_name is required; object_path
is also required. |
source code
|
|
|
|
|
remove_from_connection(self,
connection=None,
path=None)
Make this object inaccessible via the given D-Bus connection
and object path. If no connection or path is specified,
the object ceases to be accessible via any connection or path. |
source code
|
|
|
|
|
|
|
Introspect(self,
object_path,
connection)
Return a string of XML encoding this object's supported interfaces,
methods and signals. |
source code
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
SUPPORTS_MULTIPLE_OBJECT_PATHS = False
|
|
SUPPORTS_MULTIPLE_CONNECTIONS = False
|
|
|
__dbus_object_path__
The object-path at which this object is available.
Access raises AttributeError if there is no object path, or more than
one object path.
|
|
connection
The Connection on which this object is available.
Access raises AttributeError if there is no Connection, or more than
one Connection.
|
|
locations
An iterable over tuples representing locations at which this
object is available.
|
Inherited from object :
__class__
|
__init__(self,
conn=None,
object_path=None,
bus_name=None)
(Constructor)
| source code
|
Constructor. Either conn or bus_name is required; object_path
is also required.
- Parameters:
conn (dbus.connection.Connection or None) - The connection on which to export this object.
If None, use the Bus associated with the given bus_name.
If there is no bus_name either, the object is not
initially available on any Connection.
For backwards compatibility, if an instance of
dbus.service.BusName is passed as the first parameter,
this is equivalent to passing its associated Bus as
conn, and passing the BusName itself as bus_name.
object_path (str or None) - A D-Bus object path at which to make this Object available
immediately. If this is not None, a conn or bus_name must
also be provided.
bus_name (dbus.service.BusName or None) - Represents a well-known name claimed by this process. A
reference to the BusName object will be held by this
Object, preventing the name from being released during this
Object's lifetime (unless it's released manually).
- Overrides:
object.__init__
|
Make this object accessible via the given D-Bus connection and
object path.
- Parameters:
connection (dbus.connection.Connection) - Export the object on this connection. If the class attribute
SUPPORTS_MULTIPLE_CONNECTIONS is False (default), this object
can only be made available on one connection; if the class
attribute is set True by a subclass, the object can be made
available on more than one connection.
path (dbus.ObjectPath or other str) - Place the object at this object path. If the class attribute
SUPPORTS_MULTIPLE_OBJECT_PATHS is False (default), this object
can only be made available at one object path; if the class
attribute is set True by a subclass, the object can be made
available with more than one object path.
- Raises:
ValueError - if the object's class attributes do not allow the
object to be exported in the desired way.
|
remove_from_connection(self,
connection=None,
path=None)
| source code
|
Make this object inaccessible via the given D-Bus connection
and object path. If no connection or path is specified,
the object ceases to be accessible via any connection or path.
- Parameters:
connection (dbus.connection.Connection or None) - Only remove the object from this Connection. If None,
remove from all Connections on which it's exported.
path (dbus.ObjectPath or other str, or None) - Only remove the object from this object path. If None,
remove from all object paths.
- Raises:
LookupError - if the object was not exported on the requested connection
or path, or (if both are None) was not exported at all.
|
Return a string of XML encoding this object's supported interfaces,
methods and signals.
- Decorators:
@method(INTROSPECTABLE_IFACE, in_signature= '', out_signature= 's', path_keyword= 'object_path', connection_keyword= 'connection')
|
str(x)
- Overrides:
object.__repr__
- (inherited documentation)
|
__str__(self)
(Informal representation operator)
| source code
|
str(x)
- Overrides:
object.__str__
- (inherited documentation)
|
__dbus_object_path__
The object-path at which this object is available.
Access raises AttributeError if there is no object path, or more than
one object path.
Changed in 0.82.0: AttributeError can be raised.
- Get Method:
- unreachable.__dbus_object_path__(self)
- The object-path at which this object is available.
Access raises AttributeError if there is no object path, or more than
one object path.
|
connection
The Connection on which this object is available.
Access raises AttributeError if there is no Connection, or more than
one Connection.
Changed in 0.82.0: AttributeError can be raised.
- Get Method:
- unreachable.connection(self)
- The Connection on which this object is available.
Access raises AttributeError if there is no Connection, or more than
one Connection.
|
locations
An iterable over tuples representing locations at which this
object is available.
Each tuple has at least two items, but may have more in future
versions of dbus-python, so do not rely on their exact length.
The first two items are the dbus.connection.Connection and the object
path.
- Get Method:
- unreachable.locations(self)
- An iterable over tuples representing locations at which this
object is available.
|