summaryrefslogtreecommitdiff
path: root/repoze/bfg/zcml.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-11-21 03:57:56 +0000
committerChris McDonough <chrism@agendaless.com>2009-11-21 03:57:56 +0000
commit2a264f946dd98ab423b458ba8e2c1ec3b55052e1 (patch)
treea62e2118769ab8a5cf18a05d691c85c0f4f9101f /repoze/bfg/zcml.py
parent75d5a60251c9d7bdb06cdfdc01e93241ffa29cba (diff)
downloadpyramid-2a264f946dd98ab423b458ba8e2c1ec3b55052e1.tar.gz
pyramid-2a264f946dd98ab423b458ba8e2c1ec3b55052e1.tar.bz2
pyramid-2a264f946dd98ab423b458ba8e2c1ec3b55052e1.zip
Turn wrapper methods back into functions to avoid keeping around references
to Configurator in closures.
Diffstat (limited to 'repoze/bfg/zcml.py')
-rw-r--r--repoze/bfg/zcml.py36
1 files changed, 12 insertions, 24 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py
index f801c62ac..77ac4c8fa 100644
--- a/repoze/bfg/zcml.py
+++ b/repoze/bfg/zcml.py
@@ -24,6 +24,7 @@ from repoze.bfg.authentication import RepozeWho1AuthenticationPolicy
from repoze.bfg.authentication import RemoteUserAuthenticationPolicy
from repoze.bfg.authentication import AuthTktAuthenticationPolicy
from repoze.bfg.authorization import ACLAuthorizationPolicy
+from repoze.bfg.configuration import Configurator
from repoze.bfg.request import route_request_iface
from repoze.bfg.threadlocal import get_current_registry
from repoze.bfg.static import StaticRootFactory
@@ -163,7 +164,7 @@ def view(
renderer = _context.path(renderer)
def register():
- config = get_configurator(reg)
+ config = Configurator(reg)
config.view(
permission=permission, for_=for_, view=view, name=name,
request_type=request_type, route_name=route_name,
@@ -242,7 +243,7 @@ def route(_context, name, path, view=None, view_for=None,
view_renderer = _context.path(view_renderer)
def register():
- config = get_configurator(reg)
+ config = Configurator(reg)
config.route(
name,
path,
@@ -320,7 +321,7 @@ class SystemViewHandler(object):
def register(iface=self.iface):
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
config.system_view(iface, view=view, attr=attr, renderer=renderer,
wrapper=wrapper, _info=_context.info)
@@ -348,7 +349,7 @@ class IResourceDirective(Interface):
def resource(_context, to_override, override_with):
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
_context.action(
discriminator = None,
@@ -368,7 +369,7 @@ def repozewho1authenticationpolicy(_context, identifier_name='auth_tkt',
# authentication policies must be registered eagerly so they can
# be found by the view registration machinery
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
config.authentication_policy(policy, _info=_context.info)
_context.action(discriminator=IAuthenticationPolicy)
@@ -384,7 +385,7 @@ def remoteuserauthenticationpolicy(_context, environ_key='REMOTE_USER',
# authentication policies must be registered eagerly so they can
# be found by the view registration machinery
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
config.authentication_policy(policy, _info=_context.info)
_context.action(discriminator=IAuthenticationPolicy)
@@ -422,7 +423,7 @@ def authtktauthenticationpolicy(_context,
# authentication policies must be registered eagerly so they can
# be found by the view registration machinery
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
config.authentication_policy(policy, _info=_context.info)
_context.action(discriminator=IAuthenticationPolicy)
@@ -434,7 +435,7 @@ def aclauthorizationpolicy(_context):
# authorization policies must be registered eagerly so they can be
# found by the view registration machinery
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
config.authorization_policy(policy, _info=_context.info)
_context.action(discriminator=IAuthorizationPolicy)
@@ -451,7 +452,7 @@ def renderer(_context, factory, name=''):
# renderer factories must be registered eagerly so they can be
# found by the view machinery
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
config.renderer(factory, name, _info=_context.info)
_context.action(discriminator=(IRendererFactory, name))
@@ -479,7 +480,7 @@ def static(_context, name, path, cache_max_age=3600):
"""
abspath = _context.path(path)
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
_context.action(
discriminator = ('route', name, False, None, None, None, None, None),
@@ -504,7 +505,7 @@ def scan(_context, package, martian=martian):
# martian overrideable only for unit tests
def register():
reg = get_current_registry()
- config = get_configurator(reg)
+ config = Configurator(reg)
config.scan(package, _info=_context.info, martian=martian)
_context.action(discriminator=None, callable=register)
@@ -524,16 +525,3 @@ def zcml_configure(name, package):
file_configure = zcml_configure # backwards compat (>0.8.1)
-def get_configurator(reg):
- # dont create a new configurator instance unless necessary, as
- # frames will point to each configurator instance via closures
- # when some configuration methods (such as config.view) are
- # called.
- from repoze.bfg.configuration import Configurator
- try:
- config = reg.get('bfg_configurator')
- except:
- config = None
- if config is None:
- config = Configurator(reg)
- return config