--- a/src/pyams_utils/adapter.py Tue Jun 23 13:02:10 2020 +0200
+++ b/src/pyams_utils/adapter.py Tue Jun 23 13:02:59 2020 +0200
@@ -110,10 +110,12 @@
if provides is None:
raise TypeError("Missing 'provides' argument")
- config = context.config.with_package(info.module) # pylint: disable=no-member
LOGGER.debug("Registering adapter %s for %s providing %s",
str(obj), str(adapts), str(provides))
- registry = settings.get('registry', config.registry)
+ registry = settings.get('registry')
+ if registry is None:
+ config = context.config.with_package(info.module) # pylint: disable=no-member
+ registry = config.registry
registry.registerAdapter(obj, adapts, provides, settings.get('name', ''))
info = self.venusian.attach(wrapped, callback, category='pyams_adapter',
--- a/src/pyams_utils/registry.py Tue Jun 23 13:02:10 2020 +0200
+++ b/src/pyams_utils/registry.py Tue Jun 23 13:02:59 2020 +0200
@@ -238,12 +238,14 @@
else:
raise TypeError("Missing 'provides' argument")
- config = context.config.with_package(info.module) # pylint: disable=no-member
LOGGER.debug("Registering utility {0} named '{1}' providing {2}".format(
str(component) if component else str(factory),
settings.get('name', ''),
str(provides)))
- registry = settings.get('registry', config.registry)
+ registry = settings.get('registry')
+ if registry is None:
+ config = context.config.with_package(info.module) # pylint: disable=no-member
+ registry = config.registry
registry.registerUtility(component=component, factory=factory,
provided=provides, name=settings.get('name', ''))