-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Currently, plugnplay executes all implementors of a given interface in the order they were loaded. Issue #5 garantees that the same set of plugins will be loaded in the same order, every time.
This issue will add the ability to choose, per implementor, the order of its execution among all other implementors of the same interface.
The first ideia is to add an order atribute to the implementor class declaration, like this:
class MyImplementor(plugnplay.Plugin):
implements = [MyInterface,]
order = 10
This would tell plungplay that this implementor would be the 10th in the list of implementors of MyInterface. If two plugins declares the same order value, they would be ordered alphabetically.
if you want to give a high precence to a specific implementor you will be able to use order = plugnplay.FIRST, if you want to push an implementor to the end of the execution chain, you will be able to use order = plugnplay.LAST.
This will define a global order, that is, one given implementor would have the same order in every Interface it implements. This issue could evolve to implement a way of choosing an order per implemented Interface.
Something on these lines:
class MyImplementor(plugnplay.Plugin):
implements = [(MyInterface, 10), (OtherInterface, 2),]
Or like this:
class MyImplementor(plugnplay.Plugin):
implements = [(MyInterface, 10), (OtherInterface, 2),]
MyInterface_order = 10
OtherInterface_order = 2
But this could lead to a problem if some interface changes name and we forget to update the *_order line accordingly.
Anyway, just ideas. =)