zoom.config module¶
zoom.config
-
class
zoom.config.Config(directory, name, alternate=None)¶ Bases:
objectConfig file parser
The Config class looks in two places for config settings. First it looks in the site.ini file corresponding to the current site. If the value being read is not defined there it falls back to the site.ini in the default site. If the value is not found there then it returns the default value provided in the parameter list.
If no value is found it raises and exception.
>>> from zoom.tools import zoompath >>> config = Config(zoompath('web/sites/default'), 'site.ini') >>> config.get('site', 'name') 'ZOOM'
>>> config.get('site', 'value_missing', 'Got Default!') 'Got Default!'
>>> missing = False >>> try: ... config.get('site', 'value_missing') ... except Exception as e: ... missing = True >>> missing True
>>> config.has_option('site', 'name') True
>>> config.has_option('section_missing', 'name') False
>>> missing = False >>> try: ... config.get('section_missing', 'name') ... except Exception as e: ... missing = True >>> missing True
>>> target = [ ... ('administrator_group', 'administrators'), ... ('default', 'guest'), ... ('developer_group', 'developers') ... ] >>> sorted(config.items('users')) == target True
-
get(section, option, default=None)¶ Return a configuration value
-
has_option(section, option)¶
-
items(section)¶ Return a list of (name, value) tuples for each option in a section.
Both the site config and the default sites config files are read and the results combined to produce the list of tuples.
-
-
zoom.config.get_config(pathname)¶ Read a config file into a Config parser