DescriptionMove app config to the ini as the single location.
There are several constant/setting values spread out across the app. This
starts an attempt to move it into the single ini file used for the
application. It changes the web app to read them during request time and for
other apps (jobs) to be able to easily load them from the current ini file.
The ini file defaults to charmworld.ini, however it respects the ENV variable
INI for changing that at run time (say to test a different db server, etc).
test.ini
--------
Add a test.ini that is a series of settings specific to the test runner. This
allows us to run without the debug settings from the development ini. It also
allows for different settings, such as lower cache times, a different db
connection, etc.
The makefile is updated to pass the test.ini in as the INI= environment
variable.
cached_view_config
------------------
The one issue is that the appliactions settings aren't available during
config.scan() so that we can get at them in order to set the http_cache
setting. Since it's really just duped all over we add a custom
cached_view_config that reads the http_cache value from the app's ini file.
The only trick then was to support having that value be different by a
specific offset. The cached_view_config supports a new param
http_cache_modifier which is a value that is multiplied by the cache value.
This allows us to keep from hard coding any cache values, yet support the
recent routes that use a HTTP_CACHE/2 value for their cache.
initialize_db
-------------
To setup the infrastructure for moving the datastore connection info out the
initialize_db is set back up in the models code. This is like the
initialize_sql method used in sql based pyramid apps. During main() the db
connections are setup and shared through the rest of the app. Currently, the
only datastore moved is the mongo connection and to prove it works the
jobs/config.py reads the mongo connection info from the new
charmworld.utils.get_ini response.
charmworld.utils.get_ini
-------------------------
Is a new helper to fetch the correct ini file and parse the data into a
dictionary. It attempts to keep the same api expected from the pyramid parsed
version. Tests are added for this.
As a side, in order to clean up the utils.py, tests for the pretty_timedelta
were added into the new test_utils module.
https://code.launchpad.net/~rharding/charmworld/move_constants/+merge/139039
(do not edit description out of merge proposal)
Patch Set 1 #
MessagesTotal messages: 5
|