Back to index

python-cliapp  1.20120630
Public Member Functions
cliapp.plugin.Plugin Class Reference

List of all members.

Public Member Functions

def name
def description
def version
def required_application_version
def setup
def enable_wrapper
def disable_wrapper
def enable
def disable

Detailed Description

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.

Definition at line 34 of file plugin.py.


Member Function Documentation

Definition at line 80 of file plugin.py.

00080 
00081     def description(self):
00082         return ''
        
Disable the plugin.

Definition at line 122 of file plugin.py.

00122 
00123     def disable(self):
00124         '''Disable the plugin.'''
00125         raise NotImplemented()
00126 

Here is the caller graph for this function:

Corresponds to enable_wrapper, but for disabling a plugin.

Definition at line 114 of file plugin.py.

00114 
00115     def disable_wrapper(self):
00116         '''Corresponds to enable_wrapper, but for disabling a plugin.'''
00117         self.disable()
    

Here is the call graph for this function:

Enable the plugin.

Definition at line 118 of file plugin.py.

00118 
00119     def enable(self):
00120         '''Enable the plugin.'''
00121         raise NotImplemented()
    
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.

Definition at line 101 of file plugin.py.

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()

Here is the call graph for this function:

def cliapp.plugin.Plugin.name (   self)

Definition at line 76 of file plugin.py.

00076 
00077     def name(self):
00078         return self.__class__.__name__
        

Definition at line 88 of file plugin.py.

00088 
00089     def required_application_version(self):
00090         return '0.0.0'
        
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.

Definition at line 91 of file plugin.py.

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         '''
        

Definition at line 84 of file plugin.py.

00084 
00085     def version(self):
00086         return '0.0.0'
        

The documentation for this class was generated from the following file: