Server addon api: Methods to get available apps and tools#151
Conversation
Can you give example code on how one would do that? Does one just import |
Not on server. You have to know version of an addon and use addons library to get the addon. You can't simply import functions from other addons server side.
E.g. rv selection (I think) in review addon has to know structure of settings to be able to show selection of rv available. Another use-case would be enum in core for OCIO app names, which is not possible right now. It can be possible with this. |
I understand the use cases, I was asking what the code would look like. ;) How does one do this from e.g. the RV addon server-side? |
|
The desktop review now reads applications addon settings, instead it could do this. library = AddonLibrary.getinstance()
addons_by_name = await library.get_addons_by_variant(
self.settings_variant
)
addon = addons_by_name.get("applications")
if hasattr(addon, "get_application_items"):
return [
{
"value": item.full_name,
"label": item.full_label,
}
for item in addon.get_application_items()
if item.full_name.startswith("openrv/")
]
# Otherwise use the previous logic
... |
|
NOTE Also added |
BigRoy
left a comment
There was a problem hiding this comment.
The enum seems to work. Tested in: ynput/ayon-usd#124
The example however in the docstring for the apps enum resolver however is incorrect.
Also, I ended up using app_addons.latest instead of iterating the versions so that it'd always call the method from the latest app addons version.
Changelog Description
Proposal to be able to get apps and tools available for the addon versoin.
Additional review information
Added 5 new public methods to the addon. Methods
get_application_itemsandget_tool_itemsto get the items for the version of the addon. Helper methodget_addon_for_contextto get application addon version object for passed context based on project and variant. And methodsget_applications_for_contextandget_tools_for_contextwhich will find addon version based on the context and callget_application_itemsorget_tool_itemson them -> that will start to work from this version onwards.It is not really possible to support older versions as there is no way to access their code if is not part of addon classes. Without this we won't be able to do that even in future, so sooner this is merged the earlier we're able to use it.
The idea is that this can be used by other addons e.g. in settings or action forms.
Testing notes:
Validate code changes.
It should be possible to get available tools and applications from other addons.