summaryrefslogtreecommitdiff
path: root/repoze/bfg/settings.py
diff options
context:
space:
mode:
Diffstat (limited to 'repoze/bfg/settings.py')
-rw-r--r--repoze/bfg/settings.py76
1 files changed, 38 insertions, 38 deletions
diff --git a/repoze/bfg/settings.py b/repoze/bfg/settings.py
index 57295fcdc..e9a03ad0b 100644
--- a/repoze/bfg/settings.py
+++ b/repoze/bfg/settings.py
@@ -6,7 +6,45 @@ from zope.interface import implements
from repoze.bfg.interfaces import ISettings
class Settings(dict):
+ """ Deployment settings. Update application settings (usually
+ from PasteDeploy keywords) with framework-specific key/value pairs
+ (e.g. find 'BFG_DEBUG_AUTHORIZATION' in os.environ and jam into
+ keyword args)."""
implements(ISettings)
+ # _environ_ is dep inj for testing
+ def __init__(self, d=None, _environ_=os.environ, **kw):
+ if d is None:
+ d = {}
+ dict.__init__(self, d, **kw)
+ eget = _environ_.get
+ config_debug_all = self.get('debug_all', '')
+ eff_debug_all = asbool(eget('BFG_DEBUG_ALL', config_debug_all))
+ config_reload_all = self.get('reload_all', '')
+ eff_reload_all = asbool(eget('BFG_RELOAD_ALL',config_reload_all))
+ config_debug_auth = self.get('debug_authorization', '')
+ eff_debug_auth = asbool(eget('BFG_DEBUG_AUTHORIZATION',
+ config_debug_auth))
+ config_debug_notfound = self.get('debug_notfound', '')
+ eff_debug_notfound = asbool(eget('BFG_DEBUG_NOTFOUND',
+ config_debug_notfound))
+ config_reload_templates = self.get('reload_templates', '')
+ eff_reload_templates = asbool(eget('BFG_RELOAD_TEMPLATES',
+ config_reload_templates))
+ config_reload_resources = self.get('reload_resources', '')
+ eff_reload_resources = asbool(eget('BFG_RELOAD_RESOURCES',
+ config_reload_resources))
+ configure_zcml = self.get('configure_zcml', '')
+ eff_configure_zcml = eget('BFG_CONFIGURE_ZCML', configure_zcml)
+ update = {
+ 'debug_authorization': eff_debug_all or eff_debug_auth,
+ 'debug_notfound': eff_debug_all or eff_debug_notfound,
+ 'reload_templates': eff_reload_all or eff_reload_templates,
+ 'reload_resources':eff_reload_all or eff_reload_resources,
+ 'configure_zcml':eff_configure_zcml,
+ }
+
+ self.update(update)
+
def __getattr__(self, name):
# backwards compatibility
try:
@@ -30,41 +68,3 @@ def asbool(s):
s = str(s).strip()
return s.lower() in ('t', 'true', 'y', 'yes', 'on', '1')
-def get_options(kw, environ=os.environ):
- """ Update PasteDeploy application settings keywords with
- framework-specific key/value pairs (e.g. find
- 'BFG_DEBUG_AUTHORIZATION' in os.environ and jam into keyword
- args)."""
- # environ is passed in for unit tests
- eget = environ.get
- config_debug_all = kw.get('debug_all', '')
- effective_debug_all = asbool(eget('BFG_DEBUG_ALL',
- config_debug_all))
- config_reload_all = kw.get('reload_all', '')
- effective_reload_all = asbool(eget('BFG_RELOAD_ALL',
- config_reload_all))
- config_debug_auth = kw.get('debug_authorization', '')
- effective_debug_auth = asbool(eget('BFG_DEBUG_AUTHORIZATION',
- config_debug_auth))
- config_debug_notfound = kw.get('debug_notfound', '')
- effective_debug_notfound = asbool(eget('BFG_DEBUG_NOTFOUND',
- config_debug_notfound))
- config_reload_templates = kw.get('reload_templates', '')
- effective_reload_templates = asbool(eget('BFG_RELOAD_TEMPLATES',
- config_reload_templates))
- config_reload_resources = kw.get('reload_resources', '')
- effective_reload_resources = asbool(eget('BFG_RELOAD_RESOURCES',
- config_reload_resources))
- configure_zcml = kw.get('configure_zcml', '')
- effective_configure_zcml = eget('BFG_CONFIGURE_ZCML', configure_zcml)
- update = {
- 'debug_authorization': effective_debug_all or effective_debug_auth,
- 'debug_notfound': effective_debug_all or effective_debug_notfound,
- 'reload_templates': effective_reload_all or effective_reload_templates,
- 'reload_resources':effective_reload_all or effective_reload_resources,
- 'configure_zcml':effective_configure_zcml,
- }
-
- kw.update(update)
- return kw
-