Plug-In Objects

Informational Attributes

Each plug-in has several attributes which are intended to provide information to the application, and perhaps to the user as well. Because creating an object of an unknown class can cause unwanted side effects, your application can inspect these attributes by examining the plug-in class, without creating an object first. (They are also available on plug-in objects, of course.)

name (string)

The name of the plug-in. It generally matches the name of the module the plug-in is found in, but is not guaranteed to do so.

type (string)

The type of the plug-in. In all of the supplied plug-ins, the type attribute matches the name of the subpackage containing the plug-in.

properties (list [of strings])

This attribute is provided so that applications can determine the capabilities of a particular plug-in. The contents are dependent on the type of the plug-in. For example, import/export filters can have an 'import' property, an 'export' property, or both, describing which operations the filter is capable of performing. Available properties and their meanings are described elsewhere.

author (string)

The name and e-mail address of the plug-in's author, in the format it would appear in an e-mail header. For example, "Rob Tillotson <robt@debian.org>".

description (string)

A short description of the plug-in.

version (string)

The plug-in's version, in whatever format the author prefers.

url (string)

A URL at which information about the plug-in can be found.

is_plugin (boolean)

Always true; marks the class as a plug-in.

Methods

All plug-ins share a few common methods:

__call__ (...)

Activate the plug-in. The expected parameters are dependent on the plug-in's type.

has_property (property)

Returns true if the plug-in has the specified property.

log (string)

Log a string to the plug-ins log file. This function is primarily useful to the code within the plug-in itself, but it can also be used by outside code to send output to the same place the plug-in is sending it. A reference to the plug-in's log file is found in the logfile attribute of the plug-in object; the default is to send log messages to standard output.

configure (options=None)

Set the plug-in's options. The single parameter may be a dictionary of option values, keyed by name, or it may be a Registry object. If it is the latter, the option values will be looked up in the "Pyrite" section of the Registry, under a standard name based on the plug-in type and name: (<type>.<name>.<option_name>; for example, "Conduit.Backup.incremental").

If the parameter is None, the current option values will be returned as a dictionary.

gui_configure (...)

Pop up an interactive option editing dialog. At present, this method uses Tkinter, and expects a parent window as the first parameter; as the GUI portion of Pyrite becomes more complete, a method for selecting a GUI type will be added.

In addition, a plug-in object's option values are accessible as if they were attributes.