Package CedarBackup2 :: Module cli :: Class _ActionItem
[show private | hide private]
[frames | no frames]

Type _ActionItem

object --+
         |
        _ActionItem


Class representing a single action to be executed.

This class represents a single named action to be executed, and understands how to execute that action.

The built-in actions will use only the options and config values. We also pass in the config path so that extension modules can re-parse configuration if they want to, to add in extra information.

This class is also where pre-action and post-action hooks are executed. An action item is instantiated in terms of optional pre- and post-action hook objects (config.ActionHook), which are then executed at the appropriate time (if set).

Note: The comparison operators for this class have been implemented to only compare based on the index value, and ignore all other values. This is so that the action set list can be easily sorted by index.

Method Summary
  __init__(self, index, name, preHook, postHook, function)
Default constructor.
  __cmp__(self, other)
Definition of equals operator for this class.
  _executeAction(self, configPath, options, config)
Executes the action, specifically the function associated with the action.
  _executeHook(self, type, hook)
Executes a hook command via util.executeCommand().
  executeAction(self, configPath, options, config)
Executes the action associated with an item, including hooks.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__init__(self, index, name, preHook, postHook, function)
(Constructor)

Default constructor.

It's OK to pass None for index, preHook or postHook, but not for name.
Parameters:
index - Index of the item (or None).
name - Name of the action that is being executed.
preHook - Pre-action hook in terms of an ActionHook object, or None.
postHook - Post-action hook in terms of an ActionHook object, or None.
function - Reference to function associated with item.
Overrides:
__builtin__.object.__init__

__cmp__(self, other)
(Comparison operator)

Definition of equals operator for this class. The only thing we compare is the item's index.
Parameters:
other - Other object to compare to.
Returns:
-1/0/1 depending on whether self is <, = or > other.

_executeAction(self, configPath, options, config)

Executes the action, specifically the function associated with the action.
Parameters:
configPath - Path to configuration file on disk.
options - Command-line options to be passed to action.
config - Parsed configuration to be passed to action.

_executeHook(self, type, hook)

Executes a hook command via util.executeCommand().
Parameters:
type - String describing the type of hook, for logging.
hook - Hook, in terms of a ActionHook object.

executeAction(self, configPath, options, config)

Executes the action associated with an item, including hooks.

See class notes for more details on how the action is executed.
Parameters:
configPath - Path to configuration file on disk.
options - Command-line options to be passed to action.
config - Parsed configuration to be passed to action.
Raises:
Exception - If there is a problem executing the action.

Generated by Epydoc 2.1 on Thu Mar 29 20:58:30 2007 http://epydoc.sf.net