Mercurial > enso_core
changeset 56:7cbc05f5e4d7
enso.providers now caches the providers it finds for specific interfaces, and logs info messages when a provider is found for a particular interface.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 25 Feb 2008 20:55:54 -0800 |
parents | 0f8add45eae9 |
children | 9567b820b299 |
files | enso/providers.py |
diffstat | 1 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/enso/providers.py Mon Feb 25 20:36:35 2008 -0800 +++ b/enso/providers.py Mon Feb 25 20:55:54 2008 -0800 @@ -1,11 +1,22 @@ +import logging + import enso.config +_interfaces = {} + def getInterface( name ): - for provider in enso.config.PROVIDERS: - interface = provider.provideInterface( name ) - if interface: - return interface - raise ProviderNotFoundError( name ) + if name not in _interfaces: + for provider in enso.config.PROVIDERS: + interface = provider.provideInterface( name ) + if interface: + logging.info( "Obtained interface '%s' from provider '%s'." + % (name, provider.__name__) ) + _interfaces[name] = interface + break + if name in _interfaces: + return _interfaces[name] + else: + raise ProviderNotFoundError( name ) class ProviderNotFoundError( Exception ): pass