transports: when transport is a tuple the second are keyword arguments for the constructor

This commit is contained in:
Benjamin Dauvergne 2013-06-18 16:22:22 +02:00
parent 5c3b40e738
commit 1c76a88d6b
1 changed files with 5 additions and 1 deletions

View File

@ -42,10 +42,14 @@ def get_transports():
if __TRANSPORTS is None:
transports = []
for class_path in app_settings.transport_modes:
if not isinstance(class_path, basestring):
class_path, kwargs = class_path
else:
kwargs = {}
module_path, class_name = class_path.rsplit('.', 1)
try:
module = import_module(module_path)
transports.append(getattr(module, class_name)())
transports.append(getattr(module, class_name)(**kwargs))
except (ImportError, AttributeError), e:
raise ImportError('Unable to load transport class %s' % class_path, e)
__TRANSPORTS = transports