Package CedarBackup2 :: Package extend :: Module subversion :: Class LocalConfig
[show private | hide private]
[frames | no frames]

Type LocalConfig

object --+
         |
        LocalConfig


Class representing this extension's configuration document.

This is not a general-purpose configuration object like the main Cedar Backup configuration object. Instead, it just knows how to parse and emit Subversion-specific configuration values. Third parties who need to read and write configuration related to this extension should access it through the constructor, validate and addConfig methods.

Note: Lists within this class are "unordered" for equality comparisons.

Method Summary
  __init__(self, xmlData, xmlPath, validate)
Initializes a configuration object.
  __repr__(self)
Official string representation for class instance.
  __str__(self)
Informal string representation for class instance.
  __cmp__(self, other)
Definition of equals operator for this class.
  validate(self)
Validates configuration represented by the object.
  addConfig(self, xmlDom, parentNode)
Adds a <subversion> configuration section as the next child of a parent.
  _addRepository(xmlDom, parentNode, repository)
Adds a repository container as the next child of a parent. (Static method)
  _getSubversion(self)
Property target used to get the subversion configuration value.
  _parseRepositories(parent)
Reads a list of Repository objects from immediately beneath the parent. (Static method)
  _parseSubversion(parent)
Parses a subversion configuration section. (Static method)
  _parseXmlData(self, xmlData)
Internal method to parse an XML string into the object.
  _setSubversion(self, value)
Property target used to set the subversion configuration value.
    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
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
  subversion: Subversion configuration in terms of a SubversionConfig object.

Instance Method Details

__init__(self, xmlData=None, xmlPath=None, validate=True)
(Constructor)

Initializes a configuration object.

If you initialize the object without passing either xmlData or xmlPath then configuration will be empty and will be invalid until it is filled in properly.

No reference to the original XML data or original path is saved off by this class. Once the data has been parsed (successfully or not) this original information is discarded.

Unless the validate argument is False, the LocalConfig.validate method will be called (with its default arguments) against configuration after successfully parsing any passed-in XML. Keep in mind that even if validate is False, it might not be possible to parse the passed-in XML document if lower-level validations fail.
Parameters:
xmlData - XML data representing configuration.
           (type=String data.)
xmlPath - Path to an XML file on disk.
           (type=Absolute path to a file on disk.)
validate - Validate the document after parsing it.
           (type=Boolean true/false.)
Raises:
ValueError - If both xmlData and xmlPath are passed-in.
ValueError - If the XML data in xmlData or xmlPath cannot be parsed.
ValueError - If the parsed configuration document is not valid.
Overrides:
__builtin__.object.__init__

Note: It is strongly suggested that the validate option always be set to True (the default) unless there is a specific need to read in invalid configuration from disk.

__repr__(self)
(Representation operator)

Official string representation for class instance.
Overrides:
__builtin__.object.__repr__

__str__(self)
(Informal representation operator)

Informal string representation for class instance.
Overrides:
__builtin__.object.__str__

__cmp__(self, other)
(Comparison operator)

Definition of equals operator for this class. Lists within this class are "unordered" for equality comparisons.
Parameters:
other - Other object to compare to.
Returns:
-1/0/1 depending on whether self is <, = or > other.

validate(self)

Validates configuration represented by the object.

Subversion configuration must be filled in. Within that, the collect mode and compress mode are both optional, but the list of repositories must contain at least one entry.

Each BDB or FSFS repository must contain a repository path, and then must be either able to take collect mode and compress mode configuration from the parent SubversionConfig object, or must set each value on its own. We don't look at any other kinds of repositories that might be in the list.
Raises:
ValueError - If one of the validations fails.

addConfig(self, xmlDom, parentNode)

Adds a <subversion> configuration section as the next child of a parent.

Third parties should use this function to write configuration related to this extension.

We add the following fields to the document:
  collectMode    //cb_config/subversion/collectMode
  compressMode   //cb_config/subversion/compressMode
We also add groups of the following items, one list element per item:
  repository     //cb_config/subversion/repository
Parameters:
xmlDom - DOM tree as from impl.createDocument().
parentNode - Parent that the section should be appended to.

_getSubversion(self)

Property target used to get the subversion configuration value.

_parseXmlData(self, xmlData)

Internal method to parse an XML string into the object.

This method parses the XML document into a DOM tree (xmlDom) and then calls a static method to parse the subversion configuration section.
Parameters:
xmlData - XML data to be parsed
           (type=String data)
Raises:
ValueError - If the XML cannot be successfully parsed.

_setSubversion(self, value)

Property target used to set the subversion configuration value. If not None, the value must be a SubversionConfig object.
Raises:
ValueError - If the value is not a SubversionConfig

Static Method Details

_addRepository(xmlDom, parentNode, repository)

Adds a repository container as the next child of a parent.

We add the following fields to the document:
  repositoryType          repository/type
  repositoryPath          repository/abs_path
  collectMode             repository/collect_mode
  compressMode            repository/compress_mode

The <repository> node itself is created as the next child of the parent node. This method only adds one repository node. The parent must loop for each repository in the SubversionConfig object.

If repository is None, this method call will be a no-op.
Parameters:
xmlDom - DOM tree as from impl.createDocument().
parentNode - Parent that the section should be appended to.
repository - Repository to be added to the document.

_parseRepositories(parent)

Reads a list of Repository objects from immediately beneath the parent.

We read the following individual fields:
  repositoryType          type
  repositoryPath          abs_path
  collectMode             collect_mode
  compressMode            compess_mode 
The type field is optional, and if it isn't there we assume a BDB repositories. Note that we will currently ignore any repository listing which has a set type other than ["BDB", "FSFS", ]. However, we will log a warning if we do this.
Parameters:
parent - Parent node to search beneath.
Returns:
List of Repository objects or None if none are found.
Raises:
ValueError - If some filled-in value is invalid.

_parseSubversion(parent)

Parses a subversion configuration section.

We read the following individual fields:
  collectMode    //cb_config/subversion/collect_mode
  compressMode   //cb_config/subversion/compress_mode
We also read groups of the following item, one list element per item:
  repositories   //cb_config/subversion/repository
The repositories are parsed by _parseRepositories.
Parameters:
parent - Parent node to search beneath.
Returns:
SubversionConfig object or None if the section does not exist.
Raises:
ValueError - If some filled-in value is invalid.

Property Details

subversion

Subversion configuration in terms of a SubversionConfig object.
Get Method:
_getSubversion(self)
Set Method:
_setSubversion(self, value)

Generated by Epydoc 2.1 on Mon Sep 4 13:49:33 2006 http://epydoc.sf.net