Standalone publisher matching settings to current item

hi, the same question was asked before here Publish2 UI settings transfer from one item to another though not fully developed. Basically, when publishing multiple items of the same type, they end up with identical settings, even though in the ui different ones have been entered.

Now I realize, the settings passed to set_ui_settings are a list, where each item is the corresponding publish item of the same type. So when setting the ui settings, how do you figure out the index of the current item inside settings?

For instance, here I just take the first item

    def set_ui_settings(self, widget, settings):
        settings = next(iter(settings))

        if "export_options" in settings and settings["export_options"] is not None:

How do I obtain the correct index from settings?

I had to in the end result to basicaly making sure shotgrid thinks the new selection is always different item. (as shown in video )

ln: 434

        # Now figure out if we need to create/replace the widgets.
        if (
            # If we had a selection before
            # and it was of the same type as the new one.
            # self._current_tasks.is_same_task_type(new_task_selection)
            self._current_tasks == new_task_selection

and on publish item class, i had to make sure to not use options if list has multiple entries:

def set_ui_settings(self, widget, settings):
        if len(settings) > 1:
            raise NotImplementedError()
        f_sett = settings[0]
        widget.settings = f_sett.get( "export_options", {} )

OK to your question.
In order to get correct index from settings, you first have to store some unique identifier in each setting , like

settings['export_settings']['uuid'] = uuid.uuid4()

def set_ui_settings(self, widget, settings):
    for s in settings:
        if 'export_settings' not in s :
        s_uuid = s['export_settings'].get('uuid', None)
        c_uuid = self.get_ui_settings( widget ).get('export_settings', {}).get('uuid', None)
        if s_uuid and s_uuid == c_uuid:
            widget.settings = s
        elif s_uuid and c_uuid is None :
            # the first time item is accesed
            widget.settings = s 

1 Like

Haha that’s… evil. /s

I wonder if direct equality comparison would work. It’s basically calling get_ui_settings, and finding the settings in the list that match.
On the other hand, it sounds like something that should be solved inside tk-multi-publish2. I get the idea that you might want to consider what other items’ settings are, but in the base case I just wany “my” settings.

Thanks for the insight.