diff options
Diffstat (limited to '')
-rw-r--r-- | doc/Howto_Write_Plugins | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/doc/Howto_Write_Plugins b/doc/Howto_Write_Plugins new file mode 100644 index 0000000..660b45b --- /dev/null +++ b/doc/Howto_Write_Plugins @@ -0,0 +1,54 @@ +HowTo Write A Plugin For Portato +================================= + +(NOTE: The XML schema is likely to change in the future.) + +Writing a plugin is (quite) simple. You have to provide a XML file which tells portato how to communicate with the plugin and in most cases a Python module doing the actual work. This howto is not going to cover the writing of the plugin, but only the XML. + +General +------- + +So - how is a plugin is working in general? Portato defines a set of hooks (see the Hooks file for a complete list) to which your plugin can connect. For each hook you have three choices: To connect before, after or instead of the function being hooked. (Of course you can connect several times to one hook ...) The latter one should be used only if you really know what you are doing as it is likely that Portato won't work any longer after this. Also have in mind, that only one plugin can override. Thus: if several plugins want to override one hook, a randomly chosen one will get the allowance. + +For each of the "before" and "after" mode a queue exists, holding the plugins to execute. A plugin is allowed to state another plugin which should be executed after (in "before" mode) or before (in "after" mode) your plugin. The star * exists to note that this should be applied to ALL other plugins. Portato TRIES to satisfy your request... + +When you now have chosen the connect(s) to chose you write an appropriate function (or better: a Python callable) which will be given in the XML-definition to be called by Portato with the hook's arguments. (Hint: All arguments will be passed as keyword parameters. So you can easily pick the ones you need and add a "**kwargs" argument, which will take the rest. As a nice side effect you do not have to reflect any API changes which will come with additional parameters :)). + +Finally: Add an import tag stating the module to import to execute the function(s) given - and you are done. + +Sample XML +---------- + +At the point of writing this, there is no XSD or DTD - so you cannot validate the file. But this will change at some point of time ;). + +<?xml version="1.0" encoding="UTF-8" ?> +<plugin + author="Joe Smith" + name="Some small sample plugin"> + <import>plugins.sample.small</import> + + <hook + hook = "a_hook" + call = "the_calling_function"> + <connect type="after" /> + </hook> +</plugin> + +Notes: + +- The author and name attributes are mandatory. +- If you want to specify a dependency plugin the connect tag has to be like: <connect type = "after"> The other plugin we depend on </connect>. +- It is possible of course to have more than one "hook" tag. + +Additional Tags +--------------- + +Menu: + It is possible, that your plugin gets an entry in the "Plugin"-menu. Therefore you have to provide (one or more) "menu" tags: + <menu label="The Small _Plugin" call = "the_calling_menu_function" /> + + Note, that the underscore in front of a character will make it be underlined in the menu and thus accessible by a shortcut. + +Disabled: + Sometimes you don't want the plugin to be enabled by default but only if the user explicitly says so. This can be archieved by just adding the "disabled" tag: + <disabled /> |