From ca555cb4c86810af35149c702eb945c5b9400df9 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 27 May 2009 23:49:11 +0000 Subject: - Allow IAuthenticationPolicy and IAuthorizationPolicy to be overridden via ZCML registrations (do ZCML parsing after registering these in router.py). --- CHANGES.txt | 7 +++++++ repoze/bfg/router.py | 25 +++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0a476b3f0..9610e3713 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,13 @@ 0.9dev (unreleased) =================== +Features +-------- + +- Allow IAuthenticationPolicy and IAuthorizationPolicy to be + overridden via ZCML registrations (do ZCML parsing after + registering these in router.py). + Documentation ------------- diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py index 1b535c442..92fc5b58a 100644 --- a/repoze/bfg/router.py +++ b/repoze/bfg/router.py @@ -325,18 +325,6 @@ def make_app(root_factory, package=None, filename='configure.zcml', registry.registerUtility(settings, ISettings) mapper = RoutesRootFactory(root_factory) registry.registerUtility(mapper, IRoutesMapper) - populateRegistry(registry, filename, package) - if mapper.has_routes(): - # if the user had any statements in his configuration, - # use the RoutesRootFactory as the root factory - root_factory = mapper - else: - # otherwise, use only the supplied root_factory (unless it's None) - if root_factory is None: - raise ValueError( - 'root_factory (aka get_root) was None and no routes connected') - - registry.registerUtility(root_factory, IRootFactory) if authentication_policy: registry.registerUtility(authentication_policy, IAuthenticationPolicy) @@ -358,6 +346,19 @@ def make_app(root_factory, package=None, filename='configure.zcml', 'release.') registerBBBAuthn(secpol, registry) + populateRegistry(registry, filename, package) + if mapper.has_routes(): + # if the user had any statements in his configuration, + # use the RoutesRootFactory as the root factory + root_factory = mapper + else: + # otherwise, use only the supplied root_factory (unless it's None) + if root_factory is None: + raise ValueError( + 'root_factory (aka get_root) was None and no routes connected') + + registry.registerUtility(root_factory, IRootFactory) + app = Router(registry) # We push the registry on to the stack here in case any ZCA API is -- cgit v1.2.3