Tweak app.make_rattail_config() to allow caller to define some settings.

This is mostly for the sake of tests etc.
This commit is contained in:
Lance Edgar 2015-05-03 19:36:19 -05:00
parent 2f5f9c8c3c
commit 4f5c0e6bd8
3 changed files with 71 additions and 15 deletions

View file

@ -55,22 +55,28 @@ def make_rattail_config(settings):
"""
Make a Rattail config object from the given settings.
"""
# Initialize rattail config and embed it in the settings dict, to make it
# available to web requests later.
path = settings.get('edbob.config')
if not path or not os.path.exists(path):
raise ConfigurationError("Please set 'edbob.config' in [app:main] section of config "
"to the path of your config file. Lame, but necessary.")
edbob.init('rattail', path)
log.info("using rattail config file: {0}".format(path))
rattail_config = RattailConfig(edbob.config)
settings['rattail_config'] = rattail_config
rattail_config = settings.get('rattail_config')
if not rattail_config:
# Load all Rattail database engines from config, and store in settings
# dict. This is necessary e.g. in the case of a host server, to have
# access to its subordinate store servers.
rattail_engines = get_engines(rattail_config)
settings['rattail_engines'] = rattail_engines
# Initialize rattail config and embed it in the settings dict, to make it
# available to web requests later.
path = settings.get('edbob.config')
if not path or not os.path.exists(path):
raise ConfigurationError("Please set 'edbob.config' in [app:main] section of config "
"to the path of your config file. Lame, but necessary.")
edbob.init('rattail', path)
log.info("using rattail config file: {0}".format(path))
rattail_config = RattailConfig(edbob.config)
settings['rattail_config'] = rattail_config
rattail_engines = settings.get('rattail_engines')
if not rattail_engines:
# Load all Rattail database engines from config, and store in settings
# dict. This is necessary e.g. in the case of a host server, to have
# access to its subordinate store servers.
rattail_engines = get_engines(rattail_config)
settings['rattail_engines'] = rattail_engines
# Configure the database session classes. Note that most of the time we'll
# be using the Tailbone Session, but occasionally (e.g. within batch