diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-12-20 11:14:23 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-12-20 11:14:23 +0000 |
| commit | eee8fb4a6d28a2e84b313b5518914b0fe1ab043e (patch) | |
| tree | c591ed279da5c5f6725c3c9cddffb0269c8968c2 /repoze/bfg/zcml.py | |
| parent | e9c88cab25de6e0024ff0207ac6f541756a43a27 (diff) | |
| download | pyramid-eee8fb4a6d28a2e84b313b5518914b0fe1ab043e.tar.gz pyramid-eee8fb4a6d28a2e84b313b5518914b0fe1ab043e.tar.bz2 pyramid-eee8fb4a6d28a2e84b313b5518914b0fe1ab043e.zip | |
Get rid of add_adapter and add_utility APIs (config.registry.registerAdapter and config.registry.registerUtility will work).
Diffstat (limited to 'repoze/bfg/zcml.py')
| -rw-r--r-- | repoze/bfg/zcml.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index 90f863fb3..6467907db 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -612,11 +612,10 @@ def adapter(_context, factory, provides=None, for_=None, name=''): else: factory = _rolledUpFactory(factories) - reg = get_current_registry() - config = Configurator(reg, package=_context.package) + registry = get_current_registry() _context.action( discriminator = ('adapter', for_, provides, name), - callable = config.add_adapter, + callable = registry.registerAdapter, args = (factory, for_, provides, name, _context.info), ) @@ -676,8 +675,8 @@ def subscriber(_context, for_=None, factory=None, handler=None, provides=None): for_ = tuple(for_) - reg = get_current_registry() - config = Configurator(reg, _context.package) + registry = get_current_registry() + config = Configurator(registry=registry, package=_context.package) if handler is not None: _context.action( @@ -688,8 +687,8 @@ def subscriber(_context, for_=None, factory=None, handler=None, provides=None): else: _context.action( discriminator = None, - callable = config.add_subscription_adapter, - args = (factory, for_, provides, _context.info), + callable = registry.registerSubscriptionAdapter, + args = (factory, for_, provides, None, _context.info), ) class IUtilityDirective(Interface): @@ -741,12 +740,19 @@ def utility(_context, provides=None, component=None, factory=None, name=''): else: raise TypeError("Missing 'provides' attribute") - reg = get_current_registry() - config = Configurator(reg, package=_context.package) + if factory: + kw = dict(factory=factory) + else: + # older component registries don't accept factory as a kwarg, + # so if we don't need it, we don't pass it + kw = {} + + registry = get_current_registry() _context.action( discriminator = ('utility', provides, name), - callable = config.add_utility, - args = (component, provides, name, _context.info, factory), + callable = registry.registerUtility, + args = (component, provides, name, _context.info), + kw = kw, ) def path_spec(context, path): |
