diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-05-25 00:27:08 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-05-25 00:27:08 +0000 |
| commit | 267f2db66f514db43d0801237213799cd6797ee4 (patch) | |
| tree | ae13868d50a54f534bf594acf8b109d49ad60e09 /repoze/bfg/router.py | |
| parent | 6db0d49fb607f4dc55e8612e4a658856c1afbf8b (diff) | |
| download | pyramid-267f2db66f514db43d0801237213799cd6797ee4.tar.gz pyramid-267f2db66f514db43d0801237213799cd6797ee4.tar.bz2 pyramid-267f2db66f514db43d0801237213799cd6797ee4.zip | |
Change the semantics of IForbiddenAppFactory.
Diffstat (limited to 'repoze/bfg/router.py')
| -rw-r--r-- | repoze/bfg/router.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py index 885a08184..2af5df4c7 100644 --- a/repoze/bfg/router.py +++ b/repoze/bfg/router.py @@ -18,6 +18,7 @@ from repoze.bfg.interfaces import IRoutesMapper from repoze.bfg.interfaces import ISecurityPolicy from repoze.bfg.interfaces import ISettings from repoze.bfg.interfaces import IForbiddenAppFactory +from repoze.bfg.interfaces import IUnauthorizedAppFactory from repoze.bfg.interfaces import IView from repoze.bfg.interfaces import IViewPermission @@ -55,7 +56,28 @@ class Router(object): self.request_factory = registry.queryUtility(IRequestFactory) security_policy = registry.queryUtility(ISecurityPolicy) - self.forbidden_app_factory = registry.queryUtility(IForbiddenAppFactory) + unauthorized_app_factory = registry.queryUtility( + IUnauthorizedAppFactory) + + forbidden = None + + if unauthorized_app_factory is not None: + warning = ( + 'Instead of registering a utility against the ' + 'repoze.bfg.interfaces.IUnauthorizedAppFactory interface ' + 'to return a custom forbidden response, you should now ' + 'register a "repoze.interfaces.IForbiddenAppFactory". ' + 'The IUnauthorizedAppFactory interface was deprecated in ' + 'repoze.bfg 0.8.2 and will be removed in a subsequent version ' + 'of repoze.bfg. See the "Hooks" chapter of the repoze.bfg ' + 'documentation for more information about ' + 'IForbiddenAppFactory.') + self.logger and self.logger.warn(warning) + def forbidden(context, request): + return unauthorized_app_factory() + + self.forbidden_app_factory = registry.queryUtility(IForbiddenAppFactory, + default=forbidden) if security_policy is not None: if hasattr(security_policy, 'forbidden'): |
