This patch adds two class variables to plugable.Plugin: VERSION and DEPENDENCIES. VERSION is supposed to be a tuple with 2 ints specifying the plugin major and minor version number. DEPENDENCIES is supposed to be a tuple of tuples. The inner tuples will contain the plugin class name (as a string) and a major version number.
The plugable.Registrar class has changed a bit. I decided to remove the 'override' keyword argument. It wasn't used anywhere. Overriding is now automatic based on the plugin class VERSION. Higher version overrides lower. This way, we can have several versions of the same plugin living in IPA directory (not in API!) at the same time. It allows higher versions to easily build on top (extend) older ones.
There's also a new exception:PluginMissingDependencyError: Plugin 'service' is missing dependency plugin 'host' (version 1)
Plugin dependencies are checked when all plugin have been loaded, that is when API is finalizing.
An example of what we can do with this approach:Let's say a customer needs to extend users and groups by storing some additional computed information in the entries.
indentity_ex.py: from ipalib.plugins.user import user, user_add from ipalib.plugins.group import group, group_add class user(user): VERSION = (2, 0) DEPENDENCIES = (('group', 2), ) takes_params = user.takes_params + ( # some new params here ) api.register(user) class user_add(user_add): VERSION = (2, 0) def pre_callback( # I don't feel like writing all the args :) dn = super(user_add, self).pre_callback( # and again # do some new stuff here return dn api.register(user_add) # same analogous thing for groups comes here... Pavel
0001-Add-plugin-versioning-and-dependency-checking.patch
Description: application/mbox
_______________________________________________ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel