Back to index
Base class for plugins. A plugin MUST NOT have any side effects when it is instantiated. This is necessary so that it can be safely loaded by unit tests, and so that a user interface can allow the user to disable it, even if it is installed, with no ill effects. Any side effects that would normally happen should occur in the enable() method, and be undone by the disable() method. These methods must be callable any number of times. The subclass MAY define the following attributes: * name * description * version * required_application_version name is the user-visible identifier for the plugin. It defaults to the plugin's classname. description is the user-visible description of the plugin. It may be arbitrarily long, and can use pango markup language. Defaults to the empty string. version is the plugin version. Defaults to '0.0.0'. It MUST be a sequence of integers separated by periods. If several plugins with the same name are found, the newest version is used. Versions are compared integer by integer, starting with the first one, and a missing integer treated as a zero. If two plugins have the same version, either might be used. required_application_version gives the version of the minimal application version the plugin is written for. The first integer must match exactly: if the application is version 2.3.4, the plugin's required_application_version must be at least 2 and at most 2.3.4 to be loaded. Defaults to 0.
Enable plugin. The plugin manager will call this method, which then calls the enable method. Plugins should implement the enable method. The wrapper method is there to allow an application to provide an extended base class that does some application specific magic when plugins are enabled or disabled.
00101 00102 def enable_wrapper(self): 00103 '''Enable plugin. 00104 00105 The plugin manager will call this method, which then calls the 00106 enable method. Plugins should implement the enable method. 00107 The wrapper method is there to allow an application to provide 00108 an extended base class that does some application specific 00109 magic when plugins are enabled or disabled. 00110 00111 ''' 00112 00113 self.enable()
Setup plugin. This is called at plugin load time. It should not yet enable the plugin (the ``enable`` method does that), but it might do things like add itself into a hook that adds command line arguments to the application.
00091 00092 def setup(self): 00093 '''Setup plugin. 00094 00095 This is called at plugin load time. It should not yet enable the 00096 plugin (the ``enable`` method does that), but it might do things 00097 like add itself into a hook that adds command line arguments 00098 to the application. 00099 00100 '''