dasbus.server.container module
- class DBusContainer(message_bus, namespace, basename=None)[source]
Bases:
object
The container of DBus objects.
A DBus container should be used to dynamically publish Publishable objects within the same namespace. It generates a unique DBus path for each object. It is able to resolve a DBus path into an object and an object into a DBus path.
Example:
# Create a container of tasks. container = DBusContainer( namespace=("my", "project"), basename="Task", message_bus=DBus ) # Publish a task. path = container.to_object_path(MyTask()) # Resolve an object path into a task. task = container.from_object_path(path)
- from_object_path(object_path: ObjPath)[source]
Convert a DBus path to a published object.
If no published object is found for the given DBus path, raise DBusContainerError.
- Parameters
object_path – a DBus path
- Returns
a published object
- from_object_path_list(object_paths: List[ObjPath])[source]
Convert DBus paths to published objects.
- Parameters
object_paths – a list of DBus paths
- Returns
a list of published objects
- set_namespace(namespace)[source]
Set the namespace.
All DBus objects from the container should use the same namespace, so the namespace should be set up before any of the DBus objects are published.
- Parameters
namespace – a sequence of names