config¶
Each entry point of the application must instantiate a config object with an explicit path to a configuration file before any other mobyle module import. for instance:
import mobyle.common.config
cfg = mobyle.common.config.Config(file = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'development.ini')))
This will create a kind of singleton of the config object, so the other calls to config just return this object. If you have a warning like the following message:
2013-03-14 11:37:08,345 - mobyle - WARNING - No configuration file available, using defaults
then you need to check carefully the config object.
config API reference¶
Created on Nov. 27, 2012
@author: Olivier Sallou @contact: olivier.sallou@irisa.fr @license: GPLv3
- class mobyle.common.config.Config(file=None)[source]¶
Config loads mobyle configuration file.
Configuration file can be specified or loaded in $HOME/.mobyle or current directory if not specified. File also contains configuration for the logger
Config object must be instanciated once at application startup
Example: Config(‘path_to_my_configfile’)
To get access to a Config element, one must specify the section and key.
Example: Config.get(“app:main”,”db_uri”)
To get a logger, just use the following.
Example: Config.logger(“mylogger”) or Config.logger() for defaults
- static _Config__parse_config_file(file=None)¶
Parse the configuration file
Parameters: file (String) – Configuration file to parse
- static config()[source]¶
Get the configuration parser
Returns: the config parser Return type: ConfigParser See also
ConfigParser