Best approach to registering plugins up to specified order

Is there an already existing method or best practice for registering plugins up to a specific order? I couldn’t find anything in the code. Before I implemented, I wanted to make sure this didn’t already exist somewhere. If not, is there a recommend approach? For instance:

def register_plugins_op(plugins, order, op=operator.lt):
    for p in plugins:
        if op(p.order, order):
            pyblish.api.register_plugin(p)

Would a registered filter be better suited instead?

Hm, what outcome are you looking for? The order in which plug-ins are registered should not have any effect on the order in which they are run, that’s up to the conveniently named order variable.

Oh up to a specific order, sorry I misread your question.

There’s no built-in way to do that, what you’ve got there seems sensible enough.

a filter allows you to edit the registered plugins before they are run.
you could disable the plugins with order>x in the filter.

the only advantage of a filter approach is that you can easily deregister the filter, and register other filters.

see Filtering - Pyblish By Example

1 Like