Skip to content

ConfigObjectInterface

Amy Bowersox edited this page Apr 29, 2020 · 2 revisions

Interface: Config Object

When your engine factory or persistor factory objects are called to create engine or persistor objects, one of these object references is passed as a parameter. The object will always point to the specific section of the configuration file your particular component needs.

In general, any value in the configuration you receive that does not begin with an underscore character is available for you to use and specify the configuration of your component. The following methods are available for your use in retrieving the configuration data.

get method

def get(self, path, defaultval=None):

Returns a configuration property in its "native" type (such as string or integer).

Parameters:

  • path (type: str) - The name of the configuration value to be returned.
  • defaultval (type: object, optional) - A value returned if the given value is not found in the configuration. If this is not specified, the default is None.

Returns:

(type: object) The configuration value, either as specified in the configuration file, or defaulted if it did not exist.

string method

def string(self, path):

Returns a configuration property as a string, raising an exception if it isn't specified.

Parameters:

  • path (type: str) - The name of the configuration value to be returned.

Returns:

(type: str) The configuration value, either specified in the configuration file.

Raises:

  • ConfigError - If the value is not found, or is not a string type.

string_default method

def string_default(self, path, defaultval=None):

Returns a configuration property as a string, defaulting it if it isn't specified.

Parameters:

  • path (type: str) - The name of the configuration value to be returned.
  • defaultval (type: str, optional) - A value returned if the given value is not found in the configuration. If this is not specified, the default is None.

Returns:

(type: str) The configuration value, either as specified in the configuration file, or defaulted if it did not exist.