dreamhost/pecan — pull request #173 by alfredodeza (2013-01-23 23:42:08+00:00)
Title: Environment Variable implementation

The following pull request addresses Issue #172: Implements an optional ``PECAN_CONFIG`` environment variable to set a configuration path.

The docstrings in the places where configuration is loaded (or expected) has been updated to reflect that it is optional and it would be acceptable to not pass explicitly a path or a dictionary because Pecan can fallback to the environment variable.

A few tests where added to make sure the logic in the `conf_from_env` helper function is valid, and a couple of other tests where updated to reflect the fact that a fallback could happen.

As a side note, because we are now delegating the decision on what to load to logic within Pecan (for example in `configuration.set_config`) I could not determine what was the best Exception to use. At the time of modification there where 3 possible excpetions: `TypeError`, `IOError` and `RuntimeError`. I choose to normalize on `RuntimeError` and make it uniform for errors regarding loading the configuration from the environment variable.

I tried to make sure I was covering all of the places where configuration could load (testing, core, and configuration) but I would like some confirmation I am not missing anything. All tests where passing before completing this pull request.