Uranium
Application Framework
|
This class serves as a database for containers. More...
Public Member Functions | |
def | __init__ (self) |
Initialises the provider, which creates a few empty fields. More... | |
def | __getitem__ |
Gets a container with a specified ID. More... | |
def | __lt__ |
Compares container providers by their priority so that they are easy to sort. More... | |
def | __eq__ |
def | addMetadata |
Adds an item to the list of metadata. More... | |
def | getMetadata |
Gets the metadata of a specified container. More... | |
def | getAllIds (self) |
Gets a list of IDs of all containers this provider provides. More... | |
def | isReadOnly |
Returns whether a container is considered read-only by this provider. More... | |
def | loadContainer |
Loads the container with the specified ID. More... | |
def | loadMetadata |
Loads the metadata of a specified container. More... | |
def | metadata (self) |
Gets a dictionary of metadata of all containers, indexed by ID. More... | |
def | removeContainer (self, container_id) |
Delete a container from this provider. More... | |
![]() | |
def | __init__ (self) |
def | getPluginId (self) |
def | setPluginId (self, plugin_id) |
def | setVersion |
def | getVersion (self) |
This class serves as a database for containers.
A plug-in can define a new source for containers by implementing the getAllIds
, loadMetadata
and loadContainer
methods.
def UM.Settings.ContainerProvider.ContainerProvider.__init__ | ( | self | ) |
Initialises the provider, which creates a few empty fields.
def UM.Settings.ContainerProvider.ContainerProvider.__getitem__ | ( | self, | |
container_id | |||
) |
Gets a container with a specified ID.
This should be implemented lazily. An implementation should first check
container_id | The ID of a container to get. |
def UM.Settings.ContainerProvider.ContainerProvider.__lt__ | ( | self, | |
other | |||
) |
Compares container providers by their priority so that they are easy to sort.
other | The other container provider to compare with. |
def UM.Settings.ContainerProvider.ContainerProvider.addMetadata | ( | self, | |
metadata | |||
) |
Adds an item to the list of metadata.
This is intended to be called from the implementation of loadMetadata
.
def UM.Settings.ContainerProvider.ContainerProvider.getAllIds | ( | self, | |
Iterable, | |||
str | |||
) |
Gets a list of IDs of all containers this provider provides.
def UM.Settings.ContainerProvider.ContainerProvider.getMetadata | ( | self, | |
container_id | |||
) |
Gets the metadata of a specified container.
If the metadata of the container doesn't exist yet, it is loaded from the container source by the implementation of the provider.
Note that due to inheritance, this may also trigger the metadata of other containers to load.
container_id | The container to get the metadata of. |
None
if it failed to load. def UM.Settings.ContainerProvider.ContainerProvider.isReadOnly | ( | self, | |
container_id | |||
) |
Returns whether a container is considered read-only by this provider.
Some providers don't allow modifying their containers at all. Some only allow some containers to be modified.
def UM.Settings.ContainerProvider.ContainerProvider.loadContainer | ( | self, | |
container_id | |||
) |
Loads the container with the specified ID.
This is called lazily, so it should only request to load each container once and only when it's really needed. The container must be fully loaded after this is completed, so it may take some time.
def UM.Settings.ContainerProvider.ContainerProvider.loadMetadata | ( | self, | |
container_id | |||
) |
Loads the metadata of a specified container.
This will be called during start-up. It should be efficient.
container_id | The ID of the container to load the metadata of. |
def UM.Settings.ContainerProvider.ContainerProvider.metadata | ( | self, | |
Dict, | |||
str, | |||
Dict, | |||
str, | |||
Any | |||
) |
Gets a dictionary of metadata of all containers, indexed by ID.
def UM.Settings.ContainerProvider.ContainerProvider.removeContainer | ( | self, | |
container_id | |||
) |
Delete a container from this provider.
This deletes the container from the source. If it's read only, this should give an exception.
container_id | The ID of the container to remove. |