diff options
| author | Chris McDonough <chrism@agendaless.com> | 2008-10-03 20:11:06 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2008-10-03 20:11:06 +0000 |
| commit | 47b4d3ee62dfdb830a83192907b0602218f9ab5e (patch) | |
| tree | 6fe0cce905bcc39f1ab431101fe419f4197305f9 /repoze/bfg/registry.py | |
| parent | 68fe4a3a211176a282212a441d04ab53227f6bd2 (diff) | |
| download | pyramid-47b4d3ee62dfdb830a83192907b0602218f9ab5e.tar.gz pyramid-47b4d3ee62dfdb830a83192907b0602218f9ab5e.tar.bz2 pyramid-47b4d3ee62dfdb830a83192907b0602218f9ab5e.zip | |
Docs
- An "Environment and Configuration" chapter was added to the narrative
portion of the documentation.
Features
- Ensure bfg doesn't generate warnings when running under Python
2.6.
- The environment variable ``BFG_RELOAD_TEMPLATES`` is now available
(serves the same purpose as ``reload_templates`` in the config file).
- A new configuration file option ``debug_authorization`` was added.
This turns on printing of security authorization debug statements
to ``sys.stderr``. The ``BFG_DEBUG_AUTHORIZATION`` environment
variable was also added; this performs the same duty.
Bug Fixes
- The environment variable ``BFG_SECURITY_DEBUG`` did not always work.
It has been renamed to ``BFG_DEBUG_AUTHORIZATION`` and fixed.
Deprecations
- A deprecation warning is now issued when old API names from the
``repoze.bfg.templates`` module are imported.
Backwards incompatibilities
- The ``BFG_SECURITY_DEBUG`` environment variable was renamed to
``BFG_DEBUG_AUTHORIZATION``.
Diffstat (limited to 'repoze/bfg/registry.py')
| -rw-r--r-- | repoze/bfg/registry.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/repoze/bfg/registry.py b/repoze/bfg/registry.py index 9baa0452a..836d2ad6a 100644 --- a/repoze/bfg/registry.py +++ b/repoze/bfg/registry.py @@ -1,3 +1,5 @@ +import os +import sys import threading import zope.component @@ -11,7 +13,9 @@ from zope.component import getSiteManager as original_getSiteManager from zope.interface import implements from repoze.bfg.interfaces import ISettings +from repoze.bfg.interfaces import ILogger from repoze.bfg.zcml import zcml_configure +from repoze.bfg.log import make_stream_logger class ThreadLocalRegistryManager(threading.local): registry = getGlobalSiteManager() @@ -54,6 +58,10 @@ def makeRegistry(filename, package, options=None, lock=threading.Lock()): options = {} settings = Settings(options) registry.registerUtility(settings, ISettings) + if options.get('debug_authorization'): + auth_logger = make_stream_logger('repoze.bfg.authdebug',sys.stderr) + registry.registerUtility(auth_logger, ILogger, + 'repoze.bfg.authdebug') original_getSiteManager.sethook(getSiteManager) zope.component.getGlobalSiteManager = registry_manager.get zcml_configure(filename, package=package) @@ -82,9 +90,18 @@ def asbool(s): s = str(s).strip() return s.lower() in ('t', 'true', 'y', 'yes', 'on', '1') -def get_options(kw): +def get_options(kw, environ=os.environ): + # environ is passed in for unit tests + eget = environ.get + config_debug_auth = kw.get('debug_authorization', '') + effective_debug_auth = asbool(eget('BFG_DEBUG_AUTHORIZATION', + config_debug_auth)) + config_reload_templates = kw.get('reload_templates') + effective_reload_templates = asbool(eget('BFG_RELOAD_TEMPLATES', + config_reload_templates)) return { - 'reload_templates':asbool(kw.get('reload_templates')), + 'debug_authorization': effective_debug_auth, + 'reload_templates':effective_reload_templates, } from zope.testing.cleanup import addCleanUp |
